#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cout << *it << " = " << a << endl;
  err(++it, args...);
}
vector<long long> allprime;
void seive() {
  long long flag[100005] = {0};
  for (long long i = 2; i <= sqrt(100004); i++) {
    if (!flag[i]) {
      for (long long j = i * i; j <= 100004; j += i) {
        flag[j] = 1;
      }
    }
  }
  for (long long i = 2; i < 100005; i++) {
    if (!flag[i]) {
      allprime.push_back(i);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    long long n, M;
    cin >> n >> M;
    long long a[n], curr = 0;
    priority_queue<long long> pq;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      curr += a[i];
      long long req = curr - M;
      vector<int> v;
      while (req > 0) {
        v.push_back(pq.top());
        req -= pq.top();
        pq.pop();
      }
      cout << v.size() << " ";
      for (long long i = 0; i < v.size(); i++) pq.push(v[i]);
      pq.push(a[i]);
    }
  }
}
