#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  vector<long long int> v, res;
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    v.push_back(x);
  }
  long long int sum = 0;
  priority_queue<long long int> q;
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    sum += v[i];
    if (sum > m) {
      long long int tsum = sum, tans = ans;
      vector<long long int> recent;
      while (tsum > m) {
        long long int a = q.top();
        q.pop();
        tsum -= a;
        tans += 1;
        recent.push_back(a);
      }
      res.push_back(tans);
      int w = 0, ind = recent.size() - 1;
      while (w < v[i] and ind > -1) {
        w += recent[ind];
        ind -= 1;
      }
      for (int i = recent.size() - 1; i > ind; i--) {
        q.push(recent[i]);
        tsum += recent[i];
        tans -= 1;
      }
      sum = tsum;
      ans = tans;
    } else {
      res.push_back(ans);
    }
    q.push(v[i]);
  }
  for (long long int i = 0; i < n; i++) cout << res[i] << " ";
  cout << endl;
}
