#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, M;
  cin >> n >> M;
  int a[101] = {0}, t[n], c, sub, i, s = 0, j;
  for (i = 0; i < n; i++) {
    cin >> t[i];
  }
  for (i = 0; i < n; i++) {
    s = s + t[i];
    if (s <= M)
      cout << "0" << endl;
    else {
      c = 0;
      sub = s - M;
      for (j = 100; j >= 0; j--) {
        if (a[j] != 0) {
          sub = sub - (a[j] * j);
          if (sub <= 0) {
            c = c + (a[j] - (abs(sub) / j));
            break;
          }
          c = c + a[j];
        }
      }
      cout << c << endl;
    }
    a[t[i]]++;
  }
}
