#include <bits/stdc++.h>
using namespace std;
int sum = 0, A[110];
bool ok(int n, int got) {
  int ret = sum;
  for (int i = 100; i >= 0; i--) {
    if (A[i] >= n) {
      ret -= n * i;
      break;
    } else {
      ret -= A[i] * i;
      n -= A[i];
    }
  }
  return (ret <= got);
}
int main() {
  int n, m, x;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> x;
    int lo = 0, hi = i, got = m - x;
    while (lo <= hi) {
      int m = (lo + hi) / 2;
      if (ok(m, got))
        hi = m - 1;
      else
        lo = m + 1;
    }
    cout << lo << ' ';
    sum += x;
    A[x]++;
  }
  cout << endl;
}
