#include <bits/stdc++.h>
using namespace std;
long long int big_mod(long long int val, long long int pow, long long int mod);
long long int mod_inverse(long long int val, long long int mod);
string sum_of_two_strings(string a, string b);
priority_queue<int> pq;
stack<int> st;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int i, m, n, sum = 0, cnt, x;
  cin >> n >> m;
  int ans[n + 2];
  for (i = 1; i <= n; i++) {
    cin >> x;
    sum += x;
    if (sum <= m) {
      ans[i] = 0;
    } else {
      cnt = 0;
      while (sum > m) {
        cnt++;
        sum -= pq.top();
        st.push(pq.top());
        pq.pop();
      }
      ans[i] = cnt;
      while (!st.empty()) {
        pq.push(st.top());
        sum += st.top();
        st.pop();
      }
    }
    pq.push(x);
  }
  for (i = 1; i <= n; i++) {
    cout << ans[i] << ' ';
  }
  return 0;
}
long long int big_mod(long long int val, long long int pow, long long int mod) {
  long long int res = 1;
  val = val % mod;
  while (pow > 0) {
    if (pow & 1) {
      res = (res * val) % mod;
    }
    pow = pow >> 1;
    val = (val * val) % mod;
  }
  return res;
}
long long int mod_inverse(long long int val, long long int mod) {
  long long int mod1 = mod;
  if (mod == 1) {
    return 0;
  }
  long long int y = 0;
  long long int x = 1;
  long long int quotient, temp;
  while (val > 1) {
    quotient = val / mod;
    temp = mod;
    mod = val % mod;
    val = temp;
    temp = y;
    y = x - quotient * y;
    x = temp;
  }
  if (x < 0) {
    x += mod1;
  }
  return x;
}
string sum_of_two_strings(string a, string b) {
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  char c;
  string ans = "";
  int length_of_a = a.size(), length_of_b = b.size();
  int i, carry = 0, sum, length = max(length_of_a, length_of_b);
  for (i = 0; i < length; i++) {
    if (i >= length_of_a) {
      sum = (b[i] - 48) + carry;
    } else if (i >= length_of_b) {
      sum = (a[i] - 48) + carry;
    } else {
      sum = (a[i] - 48) + (b[i] - 48) + carry;
    }
    carry = sum / 10;
    sum %= 10;
    c = sum + 48;
    ans += c;
  }
  if (carry > 0) {
    ans += (carry + 48);
  }
  reverse(ans.begin(), ans.end());
  return ans;
}
