#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v;
  priority_queue<int> h;
  priority_queue<int, vector<int>, greater<int> > q;
  int x = 0;
  int ans = 0;
  int c = 0;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    x = x + t;
    if (x <= m)
      cout << ans << " ";
    else {
      int x1 = x - c;
      if (q.empty() || q.top() >= h.top() || x1 - h.top() > m) {
        while (h.empty() == false) {
          if (x1 <= m) break;
          ans++;
          x1 -= h.top();
          c += h.top();
          q.push(h.top());
          h.pop();
        }
      } else {
        q.push(h.top());
        x1 = x1 - h.top();
        c += h.top();
        h.pop();
        ans++;
        while (q.empty() == false) {
          int x2;
          x2 = x1 + q.top();
          if (x2 <= m) {
            x1 = x2;
            ans -= 1;
            c -= q.top();
            h.push(q.top());
            q.pop();
          } else
            break;
        }
      }
      cout << ans << " ";
    }
    h.push(t);
  }
  return 0;
}
