#include <bits/stdc++.h>
using namespace std;
priority_queue<long long int> pq;
long long int ans[100010];
long long int arr[100010];
int main() {
  ios_base::sync_with_stdio(false);
  long long int n, m;
  cin >> n >> m;
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  long long int totSm = 0;
  vector<long long int> v;
  for (long long int i = 0; i < n; i++) {
    v.clear();
    long long int reqdSm = m - arr[i];
    long long int temp = totSm;
    long long int an = 0;
    while (!pq.empty() && temp > reqdSm) {
      long long int tp = pq.top();
      v.push_back(tp);
      pq.pop();
      an++;
      temp -= tp;
    }
    totSm += arr[i];
    long long int sz = v.size();
    for (long long int i = 0; i < sz; i++) pq.push(v[i]);
    pq.push(arr[i]);
    ans[i] = an;
  }
  for (long long int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << '\n';
  return 0;
}
