#include <bits/stdc++.h>
using namespace std;
int solve() {
  long long int n, m;
  cin >> n >> m;
  priority_queue<long long int> q;
  long long int sm = 0;
  stack<long long int> st;
  for (long long int i = 0; i < n; i++) {
    long long int cnt = 0;
    long long int a;
    cin >> a;
    sm += a;
    while (sm > m) {
      sm -= q.top();
      st.push(q.top());
      q.pop();
      cnt++;
    }
    q.push(a);
    cout << cnt << " ";
    while (!st.empty()) {
      sm += st.top();
      q.push(st.top());
      st.pop();
    }
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
