#include <bits/stdc++.h>
using namespace std;
long long fast_pow(long long a, long long p) {
  long long res = 1;
  while (p) {
    if (p % 2 == 0) {
      a = a * 1LL * a % 1000000007;
      p /= 2;
    } else {
      res = res * 1LL * a % 1000000007;
      p--;
    }
  }
  return res;
}
long long fact(long long n) {
  long long res = 1;
  for (long long i = 1; i <= n; i++) {
    res = res * 1LL * i % 1000000007;
  }
  return res;
}
long long C(long long n, long long k) {
  return fact(n) * 1LL * fast_pow(fact(k), 1000000007 - 2) % 1000000007 * 1LL *
         fast_pow(fact(n - k), 1000000007 - 2) % 1000000007;
}
vector<long long> sieveOfEratosthenes(long long n) {
  vector<long long> primes;
  vector<bool> prime(n + 1, true);
  for (long long p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (long long i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (long long p = 2; p <= n; p++)
    if (prime[p]) primes.push_back(p);
  return primes;
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
bool isPerfectSquare(long double x) {
  if (x >= 0) {
    long long sr = sqrt(x);
    return (sr * sr == x);
  }
  return false;
}
long long sum(long long n) {
  long long res = 0;
  while (n > 0) {
    res += n % 10;
    n = n / 10;
  }
  return res;
}
vector<long long> adj[10001];
vector<long long> vis(10001);
vector<long long> col(10001);
void dfs(long long v) {
  vis[v] = 1;
  for (auto ch : adj[v]) {
    if (vis[ch] == 0) {
      dfs(ch);
    }
  }
}
bool bptdfs(long long v, long long c) {
  vis[v] = 1;
  col[v] = c;
  for (auto ch : adj[v]) {
    if (vis[ch] == 0) {
      if (bptdfs(ch, c ^ 1) == false) {
        return false;
      }
    } else {
      if (col[v] == col[ch]) {
        return false;
      }
    }
  }
  return true;
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long t = 1;
  while (t--) {
    long long n, M;
    cin >> n >> M;
    vector<long long> t(n);
    for (long long i = (0); i <= (n - 1); i++) {
      cin >> t[i];
    }
    vector<long long> ans(n, 0);
    for (long long i = (1); i <= (n - 1); i++) {
      long long c = 0, sum = 0;
      priority_queue<long long> q;
      for (long long j = (0); j <= (i); j++) {
        sum += t[j];
        if (j != i) {
          q.push(t[j]);
        }
      }
      if (sum > M) {
        while (sum > M) {
          long long x = q.top();
          q.pop();
          sum -= x;
          c++;
        }
      }
      ans[i] = c;
    }
    for (auto x : ans) {
      cout << x << " ";
    }
    cout << endl;
  }
}
