#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, M;
  cin >> n >> M;
  int a[n];
  int fre[101] = {0};
  map<long long int, int> mp;
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<long long int> ans;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      mp[a[i]]++;
      ans.push_back(0);
    } else {
      bool f = 0;
      long long int p = M - a[i];
      long long int cou = 0;
      for (auto j = mp.begin(); j != mp.end(); j++) {
        int c = j->second;
        long long int r = j->first;
        if (p - (c * r) >= 0) {
          p -= (c * r);
          cou += c;
          continue;
        } else {
          while (1) {
            if (c > 0 && (p - r) >= 0) {
              p -= r;
              c--;
              cou++;
            } else
              break;
          }
        }
        if (c != 0) {
          f = 1;
          ans.push_back(i - cou);
          break;
        }
      }
      if (!f) ans.push_back(0);
      mp[a[i]]++;
    }
  }
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
