#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
multiset<int> secik;
vector<int> ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ;
  int n, M, a, t;
  cin >> n >> M;
  long long sum = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> t;
    if (sum + t <= M) {
      ans.push_back(cnt);
    } else {
      while (sum > M) {
        auto it = secik.lower_bound(-200);
        sum += *it;
        secik.erase(it);
        cnt++;
      }
      long long temp = sum;
      int t2 = cnt;
      auto S = secik;
      while (temp + t > M) {
        auto it = S.lower_bound(-200);
        temp += *it;
        S.erase(it);
        t2++;
      }
      ans.push_back(t2);
    }
    sum += t;
    secik.insert(-t);
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
}
