#include <bits/stdc++.h>
using namespace std;
class segment_tree {
  int n;
  vector<int> t1;
  vector<int> t2;
  void change(int v, int L, int R, int i, int x) {
    if (R <= i || i < L)
      return;
    else if (L == R - 1) {
      t1[v] = x;
      t2[v] = 1;
    } else {
      change(2 * v + 1, L, (L + R) / 2, i, x);
      change(2 * v + 2, (L + R) / 2, R, i, x);
      t1[v] = t1[2 * v + 1] + t1[2 * v + 2];
      t2[v] = t2[2 * v + 1] + t2[2 * v + 2];
    }
  }
  int count_mins(int v, int L, int R, int s) {
    if (L == R - 1) {
      return 0;
    } else {
      if (t1[2 * v + 1] > s)
        return count_mins(2 * v + 1, L, (L + R) / 2, s);
      else
        return t2[2 * v + 1] +
               count_mins(2 * v + 2, (L + R) / 2, R, s - t1[2 * v + 1]);
    }
  }

 public:
  segment_tree(int _n) {
    n = _n;
    t1.resize(4 * n);
    t2.resize(4 * n);
  }
  void change(int i, int x) { change(0, 0, n, i, x); }
  int count_mins(int s) {
    if (t1[0] <= s) {
      return t2[0];
    }
    return count_mins(0, 0, n, s);
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<int> t(n);
  for (int i = 0; i < (int)(n); i++) cin >> t[i];
  vector<int> ind(n);
  iota(ind.begin(), ind.end(), 0);
  sort(ind.begin(), ind.end(),
       [&t](int i, int j) -> bool { return t[i] < t[j]; });
  vector<int> r(n);
  for (int i = 0; i < (int)(n); i++) r[ind[i]] = i;
  segment_tree s(n);
  for (int i = 0; i < (int)(n); i++) {
    cout << i - s.count_mins(m - t[i]) << " ";
    s.change(r[i], t[i]);
  }
  cout << endl;
  return 0;
}
