#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, m;
  cin >> n >> m;
  long long int arr[n + 3];
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  long long int sum = 0;
  priority_queue<long long int> ank;
  long long int cnt = 0;
  for (long long int i = 0; i < n; i++) {
    sum += arr[i];
    vector<long long int> bha;
    if (sum <= m) {
      cout << cnt << " ";
      ank.push(arr[i]);
      continue;
    }
    while (sum > m) {
      long long int k = ank.top();
      bha.push_back(k);
      sum -= k;
      cnt++;
      ank.pop();
    }
    ank.push(arr[i]);
    cout << cnt << " ";
    for (long long int i = 0; i < bha.size(); i++) {
      ank.push(bha[i]);
      sum += bha[i];
      cnt--;
    }
    while (sum > m) {
      long long int k = ank.top();
      bha.push_back(k);
      sum -= k;
      cnt++;
      ank.pop();
    }
  }
}
