#include <bits/stdc++.h>
using namespace std;
long long fsort(long long A[], int N) {
  long long i = N;
  long long j = A[i];
  while (i > 0 && j > A[i - 1]) {
    A[i] = A[i - 1];
    i--;
  }
  A[i] = j;
  return i;
}
int main() {
  long long N, M, i, j, k, e, sum = 0;
  cin >> N >> M;
  long long int A[N];
  for (i = 0, e = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
    while (e <= i && sum > M) {
      sum -= A[e++];
    }
    cout << e << " ";
    k = fsort(A, i);
    if (k <= e) {
      sum -= A[k];
      sum += A[e];
    }
    while (e > 0 && sum + A[e - 1] <= M) {
      sum += A[e - 1];
      e--;
    }
  }
  return 0;
}
