#include <bits/stdc++.h>
using namespace std;
const int N = 200004, M = 100;
int a[N], c[104], ans[N], n, m, sum[104];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    ++c[a[i]];
  }
  for (int i = n; i >= 1; i--) {
    --c[a[i]];
    int x = m - a[i], p;
    for (p = 1; p <= M; p++) {
      sum[p] = sum[p - 1] + c[p] * p;
      if (sum[p] > x) break;
    }
    if (p == M + 1)
      ans[i] = 0;
    else {
      int g = c[p] - (x - sum[p - 1]) / p;
      for (int j = p + 1; j <= M; j++) g += c[j];
      ans[i] = g;
    }
  }
  for (int i = 1; i <= n; i++) printf("%d%c", ans[i], " \n"[i == n]);
}
