#include <bits/stdc++.h>
using namespace std;
int arr[200100];
int ans[200100];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  priority_queue<int> q;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    priority_queue<int> q2 = q;
    int sum2 = sum;
    while (q2.size() > 0 && arr[i] + sum2 > m) {
      sum2 -= q2.top();
      q2.pop();
    }
    ans[i] = i - 1 - q2.size();
    q.push(arr[i]);
    sum += arr[i];
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
