#include <bits/stdc++.h>
using namespace std;
inline long long GCD(long long x, long long y) {
  long long r = x % y;
  while (r) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}
const long long N = 1e6 + 69;
void __print(long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  long long f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
signed main() {
  long long n, m;
  cin >> n >> m;
  long long t[n];
  for (long long i = 0; i < n; i++) {
    cin >> t[i];
  }
  multiset<long long> s;
  set<long long> s2;
  long long sum = 0;
  long long cnt = 0;
  vector<long long> v;
  for (long long i = 0; i < n; i++) {
    if (i == 6) {
      ;
    }
    while (sum > m && (long long)s.size()) {
      long long var = *s.rbegin();
      sum -= var;
      s.erase(s.find(var));
      cnt++;
    }
    long long p = 0;
    vector<long long> v;
    long long s1 = sum + t[i];
    if (i == 6) {
      ;
      ;
    }
    while (s1 > m && (long long)s.size()) {
      long long var = *s.rbegin();
      s1 -= var;
      p++;
      v.push_back(var);
      s.erase(s.find(var));
    }
    if (i == 6) {
      ;
    }
    cout << p + cnt << " ";
    for (long long x : v) s.insert(x);
    sum += t[i];
    s.insert(t[i]);
  }
  return 0;
}
