#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
const int INF32 = 0x3f3f3f3f;
const long long INF64 = 0x3f3f3f3f3f3f3f3f;
const long long MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = 1.0e-8;
int A[MAXN];
int Stk[MAXN], top;
int n, m;
int main() {
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 1; i <= n; ++i) scanf("%d", &A[i]);
    priority_queue<int> que;
    int sum = 0, cnt = 0;
    for (int i = 1; i <= n; ++i) {
      int tmp = sum + A[i];
      if (tmp <= m) {
        que.push(A[i]);
        sum = tmp;
        printf("%d%c", cnt, i == n ? '\n' : ' ');
        continue;
      }
      top = 0;
      if (A[i] > que.top()) {
        while (tmp > m && que.size()) {
          int u = que.top();
          que.pop();
          cnt++;
          Stk[++top] = u;
          tmp -= u;
        }
        printf("%d%c", cnt, i == n ? '\n' : ' ');
        tmp -= A[i];
        ++cnt;
        for (int j = 1; j <= top; ++j) {
          que.push(Stk[j]);
          --cnt;
          tmp += Stk[j];
        }
        sum = tmp;
        continue;
      }
      int u = que.top();
      que.pop();
      cnt++;
      tmp -= u;
      que.push(A[i]);
      printf("%d%c", cnt, i == n ? '\n' : ' ');
      sum = tmp;
    }
  }
}
