#include <bits/stdc++.h>
using namespace std;
long long inf = 1e9;
using ll = long long;
const int dx[] = {+1, -1, 0, 0};
const int dy[] = {0, 0, +1, -1};
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  vector<pair<int, int>> b;
  int pos = 0;
  for (int& x : a) {
    cin >> x;
    b.push_back({x, pos++});
  }
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  vector<int> t(n);
  t[0] = a[0];
  for (int i = 1; i < n; i++) t[i] = t[i - 1] + a[i];
  for (int i = 0; i < n; i++) {
    if (t[i] <= m) {
      cout << 0 << " ";
      continue;
    } else {
      int ok = false;
      int sum = 0, kol = 0;
      for (int j = 0; j < n; j++) {
        if (t[i] - sum <= m) {
          ok = true;
          cout << kol << " ";
          break;
        }
        if (b[j].second < i) {
          sum += b[j].first;
          kol++;
        }
      }
      if (ok == false && t[i] - sum <= m) cout << kol << " ";
    }
  }
  return 0;
}
