#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, t;
  priority_queue<int> pq;
  pq.push(0);
  int sum = 0, x = 0;
  vector<int> resrv;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> t;
    while (sum + t > m) {
      sum -= pq.top();
      if (pq.top() < t) resrv.push_back(pq.top());
      pq.pop();
      x++;
    }
    pq.push(t);
    sum += t;
    cout << x << ' ';
    while (!resrv.empty()) {
      pq.push(resrv.back());
      sum += resrv.back();
      x--;
      resrv.pop_back();
    }
  }
}
