#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  multiset<int> s;
  long long sum = 0;
  int x;
  int count = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    sum += x;
    if (sum <= m)
      cout << count << " ";
    else {
      auto it = s.rbegin();
      long long z = *it;
      int temp = 1;
      while ((sum - z) > m) {
        temp++;
        it++;
        z += *it;
      }
      cout << count + temp << " ";
    }
    s.insert(x);
    while (sum > m) {
      auto it = s.end();
      it--;
      count++;
      sum -= *it;
      s.erase(it);
    }
  }
}
