#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, M;
  cin >> n >> M;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> heap;
  int sum = 0;
  for (auto i = begin(a); i != end(a); ++i) {
    int c = 0;
    sum += *i;
    if (sum <= M) {
      cout << "0 ";
      heap.push_back(*i);
      push_heap(begin(heap), end(heap));
      continue;
    } else {
      int sum1 = sum;
      vector<int> heap1 = heap;
      while (sum1 > M) {
        sum1 -= heap1.front();
        pop_heap(begin(heap1), end(heap1));
        heap1.pop_back();
        c++;
      }
      cout << c << " ";
    }
    heap.push_back(*i);
    push_heap(begin(heap), end(heap));
  }
  return 0;
}
