#include <bits/stdc++.h>
using namespace std;
int min_leave(map<int, int, greater<int>> &freq, int excess) {
  int ans = 0;
  bool finished = false;
  for (auto it = freq.begin(); it != freq.end(); it++) {
    if (finished) break;
    int remove = it->first * it->second;
    if (remove >= excess) {
      finished = true;
      ans += (excess + it->first - 1) / it->first;
      break;
    }
    excess -= remove;
    ans += it->second;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, M;
  int k = 0;
  cin >> n >> M;
  vector<int> time(n);
  vector<int> sum(n);
  map<int, int, greater<int>> freq;
  for (int i = 0; i < n; i++) cin >> time[i];
  sum[0] = time[0];
  for (int i = 1; i < n; i++) sum[i] = time[i] + sum[i - 1];
  cout << k << ' ';
  freq[time[0]] = 1;
  for (int i = 1; i < n; i++) {
    if (sum[i] > M) k = min_leave(freq, sum[i] - M);
    cout << k << ' ';
    if (!freq.count(time[i]))
      freq[time[i]] = 1;
    else
      freq[time[i]]++;
  }
  return 0;
}
