#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int n, m;
  cin >> n >> m;
  long long int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  priority_queue<int> pq;
  long long int res[n];
  pq.push(a[0]);
  res[0] = 0;
  long long int cursum = a[0];
  long long int curcount = 0;
  for (long long int i = 1; i < n; i++) {
    if (cursum + a[i] <= m) {
      pq.push(a[i]);
      cursum += a[i];
      res[i] = curcount;
    } else {
      vector<long long int> temp;
      while (cursum + a[i] > m) {
        long long int x = pq.top();
        cursum = cursum - x;
        temp.push_back(x);
        pq.pop();
        curcount++;
      }
      res[i] = curcount;
      temp.push_back(a[i]);
      sort(temp.begin(), temp.end());
      long long int ab = 0;
      curcount++;
      while (cursum <= m and ab < temp.size()) {
        pq.push(temp[ab]);
        ab++;
        cursum += temp[ab - 1];
        curcount--;
      }
    }
  }
  for (int i = 0; i < n; i++) cout << res[i] << " ";
  return 0;
}
