#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, M;
  scanf("%d %d", &n, &M);
  priority_queue<int> a;
  priority_queue<int> deleted;
  int value;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &value);
    while (!a.empty() && !deleted.empty() && a.top() > -deleted.top()) {
      int t1 = a.top();
      int t2 = -deleted.top();
      sum -= t1;
      sum += t2;
      a.pop();
      deleted.pop();
      a.push(t2);
      deleted.push(-t1);
    }
    while (sum + value > M) {
      int max = a.top();
      sum -= max;
      a.pop();
      deleted.push(-max);
    }
    sum += value;
    a.push(value);
    while (!deleted.empty() && sum - deleted.top() <= M) {
      int min = -deleted.top();
      sum += min;
      deleted.pop();
      a.push(min);
    }
    printf("%d ", deleted.size());
  }
  return 0;
}
