#include <bits/stdc++.h>
using namespace std;
int solve(priority_queue<int> pq, int curr, int goal) {
  int cnt = 0;
  while (goal < curr) {
    int val = pq.top();
    goal += val;
    pq.pop();
    cnt++;
  }
  return cnt;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) cin >> vec[i];
  priority_queue<int> pq;
  int goal = m;
  vector<int> res(n);
  for (int i = 0; i < n; i++) {
    res[i] = solve(pq, vec[i], goal);
    pq.push(vec[i]);
    goal -= vec[i];
  }
  for (int i = 0; i < n; i++) {
    if (i != 0) cout << " ";
    cout << res[i];
  }
  cout << '\n';
  return 0;
}
