The only difference between easy and hard versions is constraints.

A session has begun at Beland State University. Many students are taking exams.

Polygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-one in order from $1$-th to $n$-th. Rules of the exam are following:  The $i$-th student randomly chooses a ticket.  if this ticket is too hard to the student, he doesn't answer and goes home immediately (this process is so fast that it's considered no time elapses). This student fails the exam.  if the student finds the ticket easy, he spends exactly $t_i$ minutes to pass the exam. After it, he immediately gets a mark and goes home. 

Students take the exam in the fixed order, one-by-one, without any interruption. At any moment of time, Polygraph Poligrafovich takes the answer from one student.

The duration of the whole exam for all students is $M$ minutes ($\max t_i \le M$), so students at the end of the list have a greater possibility to run out of time to pass the exam.

For each student $i$, you should count the minimum possible number of students who need to fail the exam so the $i$-th student has enough time to pass the exam.

For each student $i$, find the answer independently. That is, if when finding the answer for the student $i_1$ some student $j$ should leave, then while finding the answer for $i_2$ ($i_2>i_1$) the student $j$ student does not have to go home.


-----Input-----

The first line of the input contains two integers $n$ and $M$ ($1 \le n \le 100$, $1 \le M \le 100$) — the number of students and the total duration of the exam in minutes, respectively.

The second line of the input contains $n$ integers $t_i$ ($1 \le t_i \le 100$) — time in minutes that $i$-th student spends to answer to a ticket.

It's guaranteed that all values of $t_i$ are not greater than $M$.


-----Output-----

Print $n$ numbers: the $i$-th number must be equal to the minimum number of students who have to leave the exam in order to $i$-th student has enough time to pass the exam.


-----Examples-----
Input
7 15
1 2 3 4 5 6 7

Output
0 0 0 0 0 2 3 
Input
5 100
80 40 40 40 60

Output
0 1 1 2 3 


-----Note-----

The explanation for the example 1.

Please note that the sum of the first five exam times does not exceed $M=15$ (the sum is $1+2+3+4+5=15$). Thus, the first five students can pass the exam even if all the students before them also pass the exam. In other words, the first five numbers in the answer are $0$.

In order for the $6$-th student to pass the exam, it is necessary that at least $2$ students must fail it before (for example, the $3$-rd and $4$-th, then the $6$-th will finish its exam in $1+2+5+6=14$ minutes, which does not exceed $M$).

In order for the $7$-th student to pass the exam, it is necessary that at least $3$ students must fail it before (for example, the $2$-nd, $5$-th and $6$-th, then the $7$-th will finish its exam in $1+3+4+7=15$ minutes, which does not exceed $M$).

Source: codeforces | Difficulty: EASY
Tags: Sorting

Greedy algorithms


Solutions:
(n, m) = map(int, input('').split())
t = list(map(int, input('').split()))
k = []
for i in range(n):
	sum = 0
	for j in range(i + 1):
		sum += t[j]
	if sum <= m:
		k.append(0)
	else:
		q = []
		for h in range(i):
			q.append(t[h])
		q.sort()
		s = len(q) - 1
		c = 0
		p = 0
		count = 0
		z = 0
		while c == 0:
			z = 0
			for e in range(p + 1):
				z = z + q[s - e]
			count += 1
			if sum - z <= m:
				k.append(count)
				break
			p += 1
for a in k:
	print(a, end=' ')


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
prefix = [0] * n
for i in range(n):
	prefix[i] = prefix[i - 1] + arr[i]
brr = []
for i in range(n):
	if prefix[i] <= m:
		print(0, end=' ')
	else:
		brr.sort()
		ct = 0
		sm = prefix[i]
		for k in range(len(brr) - 1, -1, -1):
			sm -= brr[k]
			ct += 1
			if sm <= m:
				print(ct, end=' ')
				break
	brr.append(arr[i])
print()


(n, m) = map(int, input().split())
ar = list(map(int, input().split()))
j = 0
while j != n:
	t = count = 0
	for i in range(j + 1):
		t += ar[i]
	if t < m:
		print(0, end=' ')
	else:
		ar1 = sorted(ar[0:j])
		sm = sum(ar1)
		while sm + ar[j] > m:
			sm -= ar1[-1]
			ar1.pop(-1)
			count += 1
		print(count, end=' ')
	j += 1


from sys import stdin, stdout

def input():
	return stdin.readline().strip()
MOD = 1000000007
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = []
for i in range(n):
	x = a[:i]
	x.sort(reverse=True)
	tot = sum(x)
	count = 0
	for j in x:
		if tot <= m - a[i]:
			break
		tot -= j
		count += 1
	ans.append(count)
print(*ans)


import sys, math

def read_int():
	return int(sys.stdin.readline().strip())

def read_int_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def read_string():
	return sys.stdin.readline().strip()

def read_string_list(delim=' '):
	return sys.stdin.readline().strip().split(delim)

def print_list(l):
	print(' '.join(map(str, l)))
import heapq

def compute(diff_wanted, freqs):
	out = 0
	for i in range(99, -1, -1):
		if diff_wanted <= 0:
			break
		if freqs[i] * (i + 1) <= diff_wanted:
			diff_wanted -= freqs[i] * (i + 1)
			out += freqs[i]
		else:
			consumption = min(freqs[i], math.ceil(diff_wanted / (i + 1)))
			diff_wanted -= consumption * (i + 1)
			out += consumption
	return out
(n, m) = read_int_list()
times = read_int_list()
sum_array = [0 for _ in range(n)]
sum_array[0] = times[0]
for i in range(1, n):
	sum_array[i] = sum_array[i - 1] + times[i]
freqs = [0 for _ in range(100)]
for i in range(n):
	if sum_array[i] > m:
		ans = compute(sum_array[i] - m, freqs)
		print(ans, end=' ')
	else:
		print('0', end=' ')
	freqs[times[i] - 1] += 1
print()


(n, m) = [*map(int, input().split())]
list1 = [*map(int, input().split())]
list2 = []
for i in range(n):
	list2 = []
	for j in range(i):
		list2.append(list1[j])
	list2.sort()
	sum1 = 0
	counter1 = 0
	for k in range(i):
		sum1 += list2[k]
		if sum1 > m - list1[i]:
			counter1 = 1
			print(i - k, end=' ')
			break
	if counter1 == 0:
		print('0', end=' ')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
a = [0 for i in range(101)]
ans = []
for i in range(n):
	if i == 0:
		a[l[i]] += 1
		ans.append(0)
	else:
		s = 0
		t = m - l[i]
		count = 0
		for j in range(1, 101):
			if a[j] * j < t - s:
				s += a[j] * j
				count += a[j]
			else:
				u = (t - s) // j
				ans.append(i - count - u)
				break
		else:
			ans.append(0)
		a[l[i]] += 1
for i in ans:
	print(i, end=' ')


(n, m) = list(map(int, input().split()))
s = list(map(int, input().split()))
for i in range(n):
	if sum(s[:i]) <= m - s[i]:
		print('0', end=' ')
	else:
		(tmp, sum1) = (sorted(s[:i]), sum(s[:i]))
		tmp.reverse()
		for j in range(i):
			sum1 -= tmp[j]
			if sum1 <= m - s[i]:
				print(j + 1, end=' ')
				break


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
t = [0] * 101
for i in range(n):
	s += a[i]
	if s <= m:
		print(0, end=' ')
	else:
		diff = s - m
		ts = 0
		cnt = 0
		for j in range(1, 101):
			ts += t[101 - j] * (101 - j)
			if ts >= diff:
				cnt += t[101 - j] - (ts - diff) // (101 - j)
				break
			else:
				cnt += t[101 - j]
		print(cnt, end=' ')
	t[a[i]] += 1


(n, m) = map(int, input().split())
t = list(map(int, input().split()))
temp = []
total = 0
mostr = []
for i in range(0, n):
	if total + t[i] <= m:
		total += t[i]
		print(0, end=' ')
		mostr.append(t[i])
	else:
		mostr.sort()
		right = len(mostr) - 1
		count = 0
		result = total
		while result + t[i] > m and t[i] <= m:
			if len(mostr) > 0:
				count += 1
				result -= mostr[right]
				right -= 1
			else:
				break
		total += t[i]
		mostr.append(t[i])
		print(count, end=' ')


(n, m) = map(int, input().split())
iss = list(map(int, input().split()))
ii2 = []
for i in range(len(iss)):
	iss3 = iss[0:i]
	iss3.sort()
	iss3.reverse()
	k = 0
	ii = 0
	for j in range(i + 1):
		k += int(iss[j])
	if k <= m:
		ii2.append('0')
	else:
		while k > m:
			k -= int(iss3[0])
			iss3.pop(0)
			ii += 1
		ii2.append(str(ii))
print(' '.join(ii2))


(n, m) = list(map(int, input().split()))
if n == 1:
	print(0)
	exit(0)
t = list(map(int, input().split()))
dp = [0] * 101
ans = []
for i in range(len(t)):
	s = 0
	lim = m - t[i]
	f = False
	c = 0
	for j in range(1, 101):
		if f:
			c += dp[j]
			continue
		if dp[j]:
			if s + dp[j] * j > lim:
				c += dp[j] - (lim - s) // j
				f = True
			s += dp[j] * j
	dp[t[i]] += 1
	ans.append(c)
print(*ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list()
summ = 0
for i in range(len(a)):
	summ += a[i]
	b.append(summ)
for i in range(len(b)):
	c = a[:i]
	c.sort()
	if b[i] <= m:
		print(0, end=' ')
	else:
		diff = b[i] - m
		ctr = 0
		f = 0
		for j in range(len(c) - 1, -1, -1):
			if diff > 0:
				diff -= c[j]
				ctr += 1
			else:
				f = 1
				print(ctr, end=' ')
				break
		if f == 0:
			print(ctr, end=' ')


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
record = []
needed = 0
remain = m
dp = [0 for i in range(n)]
dp[0] = 0
remain -= s[0]
record.append(s[0])
print('0', end=' ')
for i in range(1, n):
	needed = s[i]
	if needed <= remain:
		record.append(s[i])
		remain -= needed
		dp[i] = 0
		print(dp[i], end=' ')
	else:
		temp = record.copy()
		tempRem = remain
		temp.sort()
		c = 0
		while tempRem < needed:
			tempRem += temp.pop()
			c += 1
		record.append(s[i])
		remain -= needed
		dp[i] = c
		print(c, end=' ')
print('')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = []
arr = []
s = 0
for i in range(0, n):
	s += a[i]
	if s <= m:
		ans.append(0)
		arr.append(a[i])
	else:
		d = abs(s - m)
		s1 = 0
		count = 0
		arr.sort(reverse=True)
		for j in range(0, len(arr)):
			if s1 < d:
				s1 += arr[j]
				count += 1
			else:
				break
		arr.append(a[i])
		ans.append(count)
for k in range(0, n - 1):
	print(ans[k], end=' ')
print(ans[n - 1])


(n, M) = list(map(int, input().split()))
a = list(map(int, input().split()))
k = 0
pred = []
for i in range(n):
	k += a[i]
	if k <= M:
		print(0, end=' ')
	else:
		c = k
		l = -1
		r = 0
		while c > M:
			c -= pred[l]
			l -= 1
			r += 1
		print(r, end=' ')
	pred.append(a[i])
	pred.sort()


def main():
	(n, M) = input().split(' ')
	n = int(n)
	M = int(M)
	ts = input().split(' ')
	for i in range(n):
		ts[i] = int(ts[i])
	arr = []
	s = 0
	out = []
	for i in range(n):
		val = ts[i]
		s = s + val
		if s <= M:
			out.append(0)
			arr.append(ts[i])
			continue
		so = sorted(arr, reverse=True)
		dur = s
		for j in range(len(so)):
			dur = dur - so[j]
			if dur <= M:
				out.append(j + 1)
				break
		arr.append(ts[i])
	st = ''
	for val in out:
		st = st + str(val) + ' '
	print(st)
main()


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
print('0', end=' ')
d = [c[0]]
k = c[0]
for i in c[1:]:
	k += i
	if k > b:
		d.sort(reverse=True)
		g = 0
		ll = k
		for j in d:
			g += 1
			if ll - j <= b:
				print(g, end=' ')
				break
			else:
				ll -= j
	else:
		print('0', end=' ')
	d.append(i)


from itertools import accumulate
from sys import stdin

def main():
	(N, M) = map(int, input().split())
	T = list(map(int, input().split()))
	t = list(accumulate(T))
	ans = []
	for i in range(N):
		if t[i] <= M:
			ans.append(0)
		else:
			fail = 0
			for (j, t_) in enumerate(sorted(T[:i], reverse=1), start=1):
				fail += t_
				if t[i] - fail <= M:
					ans.append(j)
					break
	print(*ans)
input = lambda : stdin.readline()
main()


(n, M) = tuple(map(int, input().split()))
times = list(map(int, input().split()))
results = []
for i in range(n):
	before = times[:i]
	btime = sum(before)
	removed = 0
	while M - btime < times[i]:
		maximum = max(before)
		before.remove(maximum)
		removed += 1
		btime -= maximum
	results.append(removed)
print(*results, sep=' ')


from bisect import insort
(n, m) = map(int, input().split())
lis = list(map(int, input().split()))
pre = [lis[0]]
for i in lis[1:]:
	pre.append(pre[-1] + i)
srt = []
res = []
for i in range(n):
	if pre[i] <= m:
		res.append(0)
	else:
		c = 0
		x = pre[i] - m
		j = len(srt) - 1
		while x > 0:
			x -= srt[j]
			j -= 1
			c += 1
		res.append(c)
	insort(srt, lis[i])
for i in res:
	print(i, end=' ')
print()


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
p = []
for i in range(len(s)):
	if sum(s[:i + 1]) <= m:
		p.append('0')
	else:
		res = 0
		g = s[:i]
		m1 = sum(s[:i + 1])
		while m1 > m:
			m1 -= g.pop(g.index(max(g)))
			res += 1
		p.append(str(res))
print(' '.join(p))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = []
sum1 = 0
ans = []
for i in range(n):
	sum1 = sum(a[:i + 1])
	cnt = 0
	while sum1 > m:
		cnt += 1
		sum1 -= b[-cnt]
	ans.append(cnt)
	b.append(a[i])
	b.sort()
print(*ans)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
c = 0
if n == 1:
	print(0)
else:
	for i in range(len(l)):
		ll = l.copy()
		count = 0
		c += l[i]
		con = c
		bhak = 0
		if c <= m:
			print(0)
		else:
			for j in range(i):
				w = max(ll[0:i - count])
				con = con - w
				bhak += 1
				if con <= m:
					print(bhak)
					break
				ll.remove(w)
				count += 1


n = list(map(int, input().split()))
b = list(map(int, input().split()))
a = []
k = 0
ww = 0
for i in b:
	k = k + i
	a.append(k)
for i in range(n[0]):
	if a[i] <= n[1]:
		print('0', end=' ')
	else:
		c = b[0:i]
		c.sort()
		co = 0
		for hh in range(len(c) - 1, -1, -1):
			co = co + c[hh]
			if a[i] - co <= n[1]:
				print(len(c) - hh, end=' ')
				break


from heapq import heappush, heappop
t = 1
for test in range(t):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	heap = []
	ans = []
	cur_sum = 0
	for i in range(n):
		tmp_sum = cur_sum
		cur = 0
		popped = []
		while tmp_sum + arr[i] > m:
			val = heappop(heap)
			tmp_sum += val
			cur += 1
			popped.append(val)
		while popped:
			heappush(heap, popped.pop())
		cur_sum += arr[i]
		heappush(heap, -arr[i])
		ans.append(cur)
	print(*ans)


import heapq as h

def gre(lst, x):
	lst.sort(reverse=True)
	c = 0
	s = 0
	for i in range(len(lst)):
		s += lst[i]
		c += 1
		if s >= x:
			return c

def pro(arr, m):
	lst = [arr[0]]
	pre = [0] * len(arr)
	ans = [0] * len(arr)
	pre[0] = arr[0]
	for i in range(1, len(arr)):
		if pre[i - 1] + arr[i] <= m:
			pre[i] = pre[i - 1] + arr[i]
		else:
			req = m - arr[i]
			hav = pre[i - 1] - req
			ans[i] = gre(lst, hav)
			pre[i] = pre[i - 1] + arr[i]
		lst.append(arr[i])
	print(*ans)
(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
pro(arr, m)


(n, m) = input().split()
m = int(m)
l = list(map(int, input().split()))
s = l[0]
print(0, end=' ')
k = []
k.append(l[0])
for j in range(1, int(n)):
	s += l[j]
	if s <= m:
		print(0, end=' ')
	else:
		k.sort(reverse=True)
		c = 0
		ts = s
		e = 0
		while e < len(k) and ts > m:
			ts -= k[e]
			c += 1
			e += 1
		print(c, end=' ')
	k.append(l[j])


inputString = input().split(' ')
students = int(inputString[0])
totalTime = int(inputString[1])
studentTimes = input().split(' ')
studentTimes = [int(i) for i in studentTimes]
leaveArr = []
for i in range(0, len(studentTimes)):
	arrTillNow = studentTimes[:i + 1]
	lastElement = studentTimes[i]
	if sum(arrTillNow) <= totalTime:
		leaveArr.append(0)
	else:
		arrTillNow.pop()
		arrTillNow.sort()
		arrTillNow.insert(0, lastElement)
		count = 0
		while sum(arrTillNow) > totalTime:
			arrTillNow = arrTillNow[:len(arrTillNow) - 1]
			count += 1
		leaveArr.append(count)
print(' '.join([str(i) for i in leaveArr]).strip())


(n, M) = map(int, input().split())
t_s = list(map(int, input().split()))
res_s = [0] * n
for i in range(1, n):
	left = t_s[:i]
	sm = sum(left) + t_s[i]
	res = 0
	while sm > M:
		m = max(left)
		res += 1
		left.remove(m)
		sm -= m
	res_s[i] = res
print(' '.join(map(str, res_s)))


(n, M) = map(int, input().split())
t = [int(x) for x in input().split()]
count = [0] * 101
s = 0
for x in t:
	d = s + x - M
	k = 0
	if d > 0:
		for i in range(100, 0, -1):
			cur_sum = i * count[i]
			if d <= cur_sum:
				k += (d + i - 1) // i
				break
			k += count[i]
			d -= cur_sum
	s += x
	count[x] += 1
	print(k, end=' ')


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(n, m) = f()
l = il()
cnt = [0] * 101
sm = 0
for i in range(n):
	d = sm + l[i] - m
	k = 0
	if d > 0:
		for j in range(100, 0, -1):
			x = j * cnt[j]
			if x >= d:
				k += (d + j - 1) // j
				break
			k += cnt[j]
			d -= x
	cnt[l[i]] += 1
	sm += l[i]
	print(k, end=' ')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = []
b = [a[0]]
for i in range(1, n):
	b.append(b[-1] + a[i])
for i in range(n):
	if b[i] > m:
		c = sorted(a[:i], reverse=True)
		k = 0
		r = b[i] - m
		while r > 0:
			r -= c[k]
			k += 1
		ans.append(k)
	else:
		ans.append(0)
print(*ans)


import heapq

def main():
	[n, limit] = list(map(int, input().split()))
	ar = list(map(int, input().split()))
	sumTillNow = 0
	i = 0
	setOfAr = list()
	m = {}
	while i < n:
		count = 0
		if sumTillNow + ar[i] > limit:
			temp = sumTillNow + ar[i]
			stack = list(setOfAr)
			while temp > limit:
				popped = stack.pop()
				temp = temp - popped
				count += 1
		if i == n - 1:
			print(count)
		else:
			print(count, end=' ')
		setOfAr.append(ar[i])
		setOfAr = sorted(setOfAr)
		sumTillNow += ar[i]
		i += 1
main()


def remove_student(n, m, l):
	for i in range(len(l)):
		if l[i] + sum(l[:i]) > m:
			nums = sorted(l[:i])
			total = l[i]
			for j in range(len(nums)):
				total += nums[j]
				if total > m:
					yield (len(nums) - j)
					break
		else:
			yield 0
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
print(' '.join(map(str, remove_student(n, m, l))))


aa = input()
bb = aa.split()
n = int(bb[0])
m = int(bb[1])
cc = input()
dd = cc.split()
e = []
for i in range(n):
	dd[i] = int(dd[i])
s = 0
tt = 0
e = []
for k in range(n):
	s = tt
	tt += dd[k]
	if dd[k] <= m - s:
		print(0, end=' ')
	else:
		c = 0
		fl = 0
		e.sort()
		for j in range(k - 1, -1, -1):
			if dd[k] <= m - s:
				print(c, end=' ')
				fl = 1
				break
			else:
				s -= e[j]
				c += 1
		if fl == 0:
			print(c, end=' ')
	e.append(dd[k])


import math, sys
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
k = m
for i in range(n):
	p = sorted(a[0:i])
	m = m - a[i]
	(c, s) = (0, 0)
	count = 0
	while c < i:
		s = s + p[c]
		if s > m:
			count += 1
		c += 1
	print(count)
	m = k


from collections import Counter as C, defaultdict as D, deque as Q
from operator import itemgetter as I
from itertools import product as P
from bisect import bisect_left as BL, bisect_right as BR, insort as INSORT
from heapq import heappush as HPUSH, heappop as HPOP
from math import floor as MF, ceil as MC, gcd as MG, factorial as F, sqrt as SQRT, inf as INFINITY, log as LOG
from sys import stdin, stdout
INPUT = stdin.readline
PRINT = stdout.write
L = list
M = map

def player1():
	print('')

def player2():
	print('')

def isPrime(n):
	for i in range(2, MC(SQRT(n)) + 1):
		if n % i == 0:
			return False
	return True

def factors(x):
	ans = []
	for i in range(1, MC(SQRT(x)) + 1):
		if x % i == 0:
			ans.append(i)
			if x % (x // i) == 0:
				ans.append(x // i)
	return ans

def checkPath(source, destination, g):
	visited = [0] * 101
	q = Q()
	q.append(source)
	visited[source] = 1
	while q:
		node = q.popleft()
		if node == destination:
			return 1
		for v in g[node]:
			if not visited[v]:
				q.append(v)
				visited[v] = 1
	return 0

def main():
	(n, m) = M(int, INPUT().split())
	t = L(M(int, INPUT().split()))
	arr = []
	ans = [0] * n
	prefix = 0
	l = 0
	for i in range(n):
		if m - prefix < t[i]:
			s = 0
			count = 0
			j = l - 1
			while 1:
				if m - (prefix - s) >= t[i]:
					break
				s += arr[j]
				count += 1
				j -= 1
			ans[i] = count
		prefix += t[i]
		INSORT(arr, t[i])
		l += 1
	print(*ans)
main()


import bisect
(n, m) = list(map(int, input().split()))
t = list(map(int, input().split()))
ans = []
tt = []
for et in t:
	st = sum(tt) + et
	td = 0
	while st > m:
		td += 1
		st -= tt[-td]
	ans += [td]
	bisect.insort_left(tt, et)
print(*ans)


import sys
line = input().split()
[n, m] = [int(x) for x in line]
line = input().split()
a = [int(x) for x in line]
s = 0
x = []
for i in range(n):
	j = i - 1
	tmp = s
	count = 0
	while j >= 0 and tmp > m - a[i]:
		tmp -= x[j]
		j -= 1
		count += 1
	sys.stdout.write(str(count) + ' ')
	x.append(a[i])
	x.sort()
	s += a[i]


(n, m) = input().split()
m = int(m)
t = [int(x) for x in input().split()]
l = []
for i in t:
	count = 0
	n = l[:]
	if sum(l) + i <= m:
		print(0, end=' ')
	else:
		l.sort()
		while sum(l) + i > m:
			l.remove(l[-1])
			count += 1
		print(count, end=' ')
	n.append(i)
	l = n


import sys, math

def read_int():
	return int(sys.stdin.readline().strip())

def read_int_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def read_string():
	return sys.stdin.readline().strip()

def read_string_list(delim=' '):
	return sys.stdin.readline().strip().split(delim)

def print_list(l):
	print(' '.join(map(str, l)))
(n, m) = read_int_list()
times = read_int_list()
for i in range(n):
	if sum(times[:i]) + times[i] > m:
		sorted_times = sorted(times[:i], reverse=True)
		for j in range(i):
			if sum(times[:i]) + times[i] - sum(sorted_times[:j + 1]) <= m:
				print(j + 1, end=' ')
				break
	else:
		print('0', end=' ')
print()


import sys
input = sys.stdin.readline
(n, M) = map(int, input().split())
T = list(map(int, input().split()))
print(0)
S = [T[0]]
import bisect
for t in T[1:]:
	NOW = sum(S) + t
	count = 0
	for s in S[::-1]:
		if NOW <= M:
			print(count)
			break
		NOW -= s
		count += 1
	else:
		print(count)
	bisect.insort(S, t)


from bisect import *
R = lambda : map(int, input().split())
(n, m) = R()
a = [101]
for t in R():
	s = i = 0
	while s + t <= m:
		s += a[i]
		i += 1
	print(len(a) - i)
	a.insert(bisect_left(a, t), t)


a = [int(i) for i in input().split()]
n = a[0]
M = a[1]
x = [int(i) for i in input().split()]
pref = [0 for i in x]
pref[0] = x[0]
arr = [i for i in x]
for i in range(1, n):
	pref[i] = pref[i - 1] + x[i]
for i in range(n):
	ans = pref[i]
	if ans <= M:
		print(0, end=' ')
	else:
		arr = sorted(x[:i], reverse=True)
		k = 0
		while ans > M:
			ans -= arr[k]
			k += 1
		print(k, end=' ')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = {}
for i in range(1, 101):
	b[i] = 0
for i in range(n):
	su = a[i]
	(cn, fg) = (1, 0)
	for j in range(1, 101):
		if su + j * b[j] > m:
			break
		cn = cn + b[j]
		su += b[j] * j
	else:
		fg = 1
	if fg == 0:
		cn += (m - su) // j
		su += j * ((m - su) // j)
	b[a[i]] += 1
	print(i + 1 - cn, end=' ')


(nStudents, duration) = map(int, input().split())
t = list(map(int, input().split()))
ret = []
before = 0
for i in range(nStudents):
	if duration - before >= t[i]:
		ret.append(0)
	else:
		studentsBefore = sorted(t[:i])
		tempBefore = before
		remove = i - 1
		while duration - tempBefore < t[i]:
			tempBefore -= studentsBefore[remove]
			remove -= 1
		ret.append(i - remove - 1)
	before += t[i]
print(*ret)


def sumf(l):
	s = 0
	for i in range(0, len(l)):
		s += l[i]
	return s

def f(list1, i, m):
	count = 0
	sum = 0
	list2 = []
	for x in range(0, i + 1):
		sum = sum + list1[x]
		list2.append(list1[x])
	if sum <= m:
		print(0, end=' ')
	else:
		list2.pop(-1)
		list2.sort()
		while sumf(list2) > m - list1[i]:
			list2.pop(-1)
			count += 1
		print(count, end=' ')
(n, m) = map(int, input().split())
l = input().split()
l = list(map(int, l))
for i in range(0, n):
	f(l, i, m)


(n, m) = map(int, input().split())
ar = list(map(int, input().split()))
d = []
for i in range(n):
	summ = 0
	for j in range(i + 1):
		summ += ar[j]
	if summ <= m:
		d.append(0)
	else:
		cnt = 0
		arr = ar[:i]
		arr.sort()
		t = len(arr) - 1
		summ = sum(arr) + ar[j]
		while summ > m:
			summ -= arr[t]
			t -= 1
			cnt += 1
		d.append(cnt)
print(*d)


import math
(n, M) = map(int, input().split())
ti = list(map(int, input().split()))
li = [0 for _ in range(101)]
ans = []
summ = 0
for i in ti:
	summ += i
	su = summ
	count = 0
	if su > M:
		for ii in range(100, -1, -1):
			if su <= M:
				break
			elif su - li[ii] * ii > M:
				count += li[ii]
				su -= li[ii] * ii
			else:
				count += math.ceil((su - M) / ii)
				su -= math.ceil((su - M) / ii) * ii
				break
	ans.append(count)
	li[i] += 1
print(*ans)


import sys
IS_LOCAL = False

def readMultiple(f):
	return f(map(int, input().split()))

def main():
	(n, m) = (7, 15)
	s = [1, 2, 3, 4, 5, 6, 7]
	if not IS_LOCAL:
		(n, m) = readMultiple(tuple)
		s = readMultiple(list)
	for i in range(n):
		dm = m - s[i]
		a = sorted(s[:i].copy())
		(x, j) = (0, 0)
		while j < len(a) and x + a[j] <= dm:
			x += a[j]
			j += 1
		print(len(a) - j)
if len(sys.argv) > 1 and sys.argv[1] == 'True':
	IS_LOCAL = True
main()


(n, s) = [int(x) for x in input().split(' ')]
arr = [int(x) for x in input().split(' ')]
arr2 = [arr[0]]
for x in range(1, n):
	arr2.append(arr2[-1] + arr[x])
ans = [0]
for i in range(1, n):
	if arr2[i] <= s:
		ans.append(0)
	else:
		temp = sorted(arr[:i])
		temp2 = [temp[0]]
		for _ in range(1, len(temp)):
			temp2.append(temp2[-1] + temp[_])
		x = i - 1
		c = 0
		while x >= 0 and temp2[x] + arr[i] > s:
			c += 1
			x -= 1
		ans.append(c)
for item in ans:
	print(item, end=' ')


(n, m) = map(int, input().split())
A = [int(x) for x in input().split()]
print(0, end=' ')
i = 1
while i < n:
	p = 0
	k = m - A[i]
	cnt = 0
	B = sorted(A[:i])
	while p < i and k - B[p] >= 0:
		k -= B[p]
		p += 1
	print(i - p, end=' ')
	i += 1


import queue
from heapq import heappush as insert, heappop as extract_maximum
(n, M) = map(int, input().split())
data = list(map(int, input().split()))
true_sum = 0
true_tempo = []
for i in range(len(data)):
	tempo = true_tempo.copy()
	true_sum += data[i]
	sum = true_sum
	cnt = 0
	while sum > M:
		sum -= abs(extract_maximum(tempo))
		cnt += 1
	print(cnt, end=' ')
	insert(true_tempo, -1 * data[i])


(n, M) = map(int, input().split())
t = [int(i) for i in input().split()]
for i in range(n):
	s = t[i]
	finish_t = sum(t[:i + 1])
	if finish_t > M:
		prev_t = t[:i]
		prev_t.sort()
		left_s = 0
		while finish_t > M:
			finish_t -= prev_t.pop(len(prev_t) - 1)
			left_s += 1
		print(left_s, end=' ')
	else:
		print(0, end=' ')


a = [int(i) for i in input().split()]
n = a[0]
M = a[1]
x = [int(i) for i in input().split()]
pref = [0 for i in x]
pref[0] = x[0]
freq = [0 for i in range(100)]
for i in range(1, n):
	pref[i] = pref[i - 1] + x[i]
for j in range(n):
	ans = pref[j]
	if ans <= M:
		print(0, end=' ')
	else:
		k = 0
		while ans > M:
			for i in range(99, -1, -1):
				if freq[i] == 0:
					continue
				y = (ans - M) // (i + 1)
				if y == 0:
					ans = ans - (i + 1)
					k += 1
				elif freq[i] <= y:
					ans = ans - freq[i] * (i + 1)
					k += freq[i]
				elif ans - y * (i + 1) <= M:
					ans = ans - y * (i + 1)
					k += y
				else:
					ans = ans - (y + 1) * (i + 1)
					k += y + 1
				if ans <= M:
					break
		print(k, end=' ')
	freq[x[j] - 1] += 1


from heapq import *
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = []
h = []
for i in a:
	l = h.copy()
	heappush(h, -i)
	c = 0
	while -sum(l) + i > m:
		heappop(l)
		c += 1
	ans.append(c)
print(*ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
	if sum(a[:i + 1]) <= m:
		print(0, end=' ')
	else:
		ans = 0
		dop = a[:i]
		tc = sum(a[:i + 1])
		while tc > m:
			tc -= dop.pop(dop.index(max(dop)))
			ans += 1
		print(ans, end=' ')


(n, m) = map(int, input().split())
c = [0] * 101
a = list(map(int, input().split()))
for i in range(n):
	ans = 0
	sm = a[i]
	for j in range(1, 101):
		k = min((m - sm) // j, c[j])
		ans += k
		sm += k * j
	print(i - ans)
	c[a[i]] += 1


import bisect
(n, m) = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
s = [t[0]]
ans = '0'
k = t[0]
for i in t[1:]:
	k += i
	if k <= m:
		ans = ans + ' ' + '0'
	else:
		j = 1
		h = 0
		while h < k - m:
			h += s[-j]
			j += 1
		ans = ans + ' ' + str(j - 1)
	bisect.insort(s, i)
print(ans)


(n, M) = map(int, input().split())
t = [int(x) for x in input().split()]
for i in range(n):
	na = t[:i]
	na.sort(reverse=True)
	c = 0
	s = sum(na)
	for j in na:
		if s + t[i] <= M:
			break
		elif s - j + t[i] <= M:
			c = c + 1
			break
		else:
			c = c + 1
			s = s - j
	print(c, end=' ')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
su = 0
ans = []
for i in range(n):
	su += l[i]
	if su <= m:
		ans.append(0)
	else:
		r = l[0:i]
		r.sort(reverse=True)
		temp = 0
		for j in range(len(r)):
			temp += r[j]
			if su - temp <= m:
				ans.append(j + 1)
				break
print(*ans)


(n, m) = map(int, input().split())
n = list(map(int, input().split()))
b = []
c = []
for i in range(len(n)):
	t = 0
	e = 0
	if i > 0:
		b.append(n[i - 1])
		b.sort(reverse=True)
	for a in range(len(n) - (len(n) - i)):
		t += n[a]
	t += n[i]
	if t <= m:
		c.append(0)
	else:
		while t > m:
			t -= b[e]
			e += 1
		c.append(e)
print(*c)


from copy import deepcopy
iarr = list(map(int, input().split()))
n = iarr[0]
m = iarr[1]
tar = list(map(int, input().split()))
freq = [0 for i in range(101)]
for i in range(n):
	rem = m - tar[i]
	count = 0
	counthr = 0
	for j in range(1, 101):
		afteradd = counthr + freq[j] * j
		if afteradd > rem:
			count += (rem - counthr) // j
			counthr += count * j
			break
		elif afteradd == rem:
			counthr = afteradd
			count += freq[j]
			break
		else:
			counthr = afteradd
			count += freq[j]
	freq[tar[i]] += 1
	print(i - count, end=' ')
print()


def find_min(ar, count, m):
	ans = 0
	total = ar
	for i in range(100, 0, -1):
		total += count[i] * i
	for i in range(100, 0, -1):
		if total <= m:
			break
		if count[i] == 0:
			continue
		diff = total - m
		req = diff // i
		if diff % i > 0:
			req += 1
		cur = min(req, count[i])
		ans += cur
		total -= cur * i
	return ans
(n, m) = map(int, input().split())
ar = list(map(int, input().split()))
count = [0] * 101
print(0, end=' ')
count[ar[0]] += 1
for i in range(1, n):
	print(find_min(ar[i], count, m), end=' ')
	count[ar[i]] += 1


(n, m) = list(map(int, input().split()))
t = list(map(int, input().split()))
freq = []
for i in range(101):
	freq.append(0)
for i in range(0, n):
	time = m - t[i]
	num = 0
	for j in range(1, 101):
		p = int(time / j)
		if p >= freq[j]:
			time -= freq[j] * j
			num += freq[j]
		else:
			time -= p * j
			num += p
	print(i - num, end=' ')
	freq[t[i]] += 1


(n, m) = map(int, input().split())
array = list(map(int, input().split()))
counts = [0] * 101
answer = []
s = 0
for i in range(n):
	s += array[i]
	ans = 0
	s_in_iteration = s - m
	for j in range(100, 0, -1):
		if s_in_iteration > 0:
			count = (s_in_iteration + j - 1) // j
			if count > counts[j]:
				s_in_iteration -= counts[j] * j
				ans += counts[j]
			else:
				ans += count
				break
		else:
			break
	answer.append(ans)
	counts[array[i]] += 1
print(*answer)


from sys import stdin
(n, m) = map(int, stdin.readline().strip().split())
s = list(map(int, stdin.readline().strip().split()))
ans = [0 for i in range(n)]
sm = [0 for i in range(n)]
sm1 = [0 for i in range(n)]
for i in range(n):
	if i == 0:
		sm[i] = s[i]
	else:
		sm[i] = sm[i - 1] + s[i]
for i in range(n - 1, -1, -1):
	if i == n - 1:
		sm1[i] = s[i]
	else:
		sm1[i] = sm1[i + 1] + s[i]
for i in range(n):
	if sm[i] <= m:
		continue
	x = sm[i]
	s2 = s[0:i]
	s2.sort()
	r = 0
	while x > m:
		x -= s2[-1]
		s2.pop()
		r += 1
	ans[i] = r
print(*ans)


(n, m) = map(int, input().split())
(tot_sum, curr_sum, d) = (0, 0, {})
arr = list(map(int, input().split()))
for x in arr:
	tot_sum += x
	curr_sum += x
	curr_res = 0
	for it in sorted(d.keys(), reverse=True):
		if curr_sum <= m:
			break
		take = min(d[it], (curr_sum - m + it - 1) // it)
		curr_sum -= take * it
		curr_res += take
	d[x] = 1 if x not in d else d[x] + 1
	curr_sum = tot_sum
	print(curr_res, end=' ')


(n, m) = tuple(map(int, input().split()))
a = list(map(int, input().split()))
r = [0 for _ in range(n)]
b = [a[0]]
for i in range(1, n):
	left = m - a[i]
	(s, j) = (0, 0)
	for jr in range(0, i):
		if s + b[jr] > left:
			break
		s += b[jr]
		j += 1
	r[i] = i - j
	b.append(a[i])
	b.sort()
print(*r, sep=' ')


(n, k) = map(int, input().split())
l = list(map(int, input().split()))

def sum1(a):
	summ = 0
	for i in range(a):
		summ = summ + l[i]
	return summ
b = []
for i in range(n):
	h = []
	for j in range(i):
		h.append(l[j])
	h.sort(reverse=True)
	c = 0
	u = sum1(i + 1)
	if u > k:
		while u > k:
			u = u - h[c]
			c = c + 1
	if u <= k:
		b.append(c)
for i in range(len(b)):
	print(b[i])


import sys
from heapq import heappop, heappush, heapify
heap = []
heapify(heap)
for _ in range(1):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	ans = [0] * n
	(a, b) = (0, 0)
	for i in range(n):
		temp = []
		while a + l[i] > k:
			temp.append(heappop(heap))
			a += temp[-1]
		ans[i] = len(temp) + b
		while temp:
			a -= temp[-1]
			heappush(heap, temp.pop())
		a += l[i]
		heappush(heap, -l[i])
		if a > k:
			a += heappop(heap)
			b += 1
	print(*ans)


import heapq
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
cur = 0
ans = []
val = []
for i in range(n):
	cur += l[i]
	if cur <= m:
		ans.append(0)
		val.append(l[i])
	else:
		count = 0
		extra = []
		heapq._heapify_max(val)
		c = cur
		while c > m:
			x = heapq._heappop_max(val)
			extra.append(x)
			c -= x
			count += 1
		val.append(l[i])
		val += extra
		ans.append(count)
print(*ans)


n = []
t = []
n = list(map(int, input().split()))
t = list(map(int, input().split()))
result = []
for i in range(len(t)):
	number = int(0)
	x = t[0:i + 1]
	re = int(0)
	for j in range(i + 1):
		re += x[j]
	x.pop(i)
	while re > n[1]:
		re -= max(x)
		x.pop(x.index(max(x)))
		number += 1
	result.append(number)
print(' '.join((str(x) for x in result)))


import sys
from collections import Counter
from heapq import heappush, heappop
(n, m) = map(int, sys.stdin.readline().split())
times = list(map(int, sys.stdin.readline().split()))
remainings = []
removemes = []
time_remaining = 0
len_removed = 0
res = []
for t in times:
	while time_remaining + t > m:
		tmp = -1 * heappop(remainings)
		time_remaining -= tmp
		len_removed += 1
		heappush(removemes, tmp)
	res.append(str(len_removed))
	if bool(removemes) and t > removemes[0]:
		heappush(removemes, t)
		len_removed += 1
		while bool(removemes) and t > removemes[0]:
			tmp = heappop(removemes)
			len_removed -= 1
			heappush(remainings, -1 * tmp)
			time_remaining += tmp
	else:
		heappush(remainings, -1 * t)
		time_remaining += t
print(' '.join(res))


(n, maxi) = list(map(int, input().split()))
List = list(map(int, input().split()))
List2 = ['0']
for i in range(1, n):
	c = List[:]
	count = 0
	while sum(c[:i]) > maxi - c[i]:
		index = c.index(max(c[:i]))
		c[index] = 0
		count += 1
	List2.append(str(count))
print(' '.join(List2))


import bisect
(n, M) = list(map(int, input().split()))
nums = list(map(int, input().split()))
sorted_list = []
tm = 0
for i in range(n):
	ans = 0
	tm += nums[i]
	if tm > M:
		extra = tm - M
		red = 0
		while red < extra:
			red += sorted_list[i - 1 - ans]
			ans += 1
	bisect.insort(sorted_list, nums[i])
	print(ans, end=' ')


from bisect import *
(N, M) = input().split()
nums = [int(x) for x in input().split()]
pre = [0]
for n in nums:
	pre.append(pre[-1] + n)
pre = pre[1:]
sor = []
ans = ''
for i in range(len(pre)):
	if pre[i] > int(M):
		cnt = 0
		sm = 0
		for j in range(len(sor) - 1, -1, -1):
			sm += sor[j]
			cnt += 1
			if sm >= pre[i] - int(M):
				break
		ans += str(cnt) + ' '
	else:
		ans += '0 '
	insort(sor, nums[i])
print(ans[:len(ans) - 1])


f = []
f.append(0)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
for i in range(1, n):
	s = []
	for j in range(i):
		s.append(a[j])
	k = m - a[i]
	c = 0
	s.sort()
	for ele in s:
		if ele <= k:
			k -= ele
			c += 1
	d = i - c
	f.append(d)
for ele in f:
	print(ele, end=' ')


(n, m) = map(int, input().split())
data = list(map(int, input().split()))
a = []
for i in data:
	count = 0
	b = list(a)
	while sum(b) + i > m:
		mmm = max(b)
		b.remove(mmm)
		count += 1
	a.append(i)
	print(count, end=' ')


def solve(s, t):
	pass
(n, m) = map(int, input().split())
Time = list(map(int, input().split()))
Sum = [0] * n
Sum[0] = Time[0]
for i in range(1, n):
	Sum[i] += Sum[i - 1] + Time[i]
for i in range(n):
	if Sum[i] <= m:
		print(0, end=' ')
	else:
		LL = Time[:i]
		LL.sort()
		s = Sum[i]
		while m < s:
			p = LL.pop()
			s -= p
		print(i - len(LL), end=' ')


gi = lambda : list(map(int, input().strip().split()))
(n, m) = gi()
l = gi()
print(0, end=' ')
a = [l[0]]
for k in range(1, n):
	a.sort(reverse=True)
	tmp = m - sum(a) - l[k]
	i = 0
	while tmp < 0:
		tmp += a[i]
		i += 1
	print(i, end=' ')
	a.append(l[k])


def fail_student(n, m, l):
	(d, k, s, t, j) = ([], [], 0, 0, 0)
	for i in l:
		s += i
		t = s
		j = 0
		while t > m:
			t -= k[j]
			j += 1
		k.append(i)
		k.sort(reverse=True)
		d.append(j)
	print(*d)
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
fail_student(n, m, l)


(n, M) = map(int, input().split())
l = list(map(int, input().split()))
L = []
s = 0
for i in range(n):
	ans = 0
	r = s + l[i]
	k = len(L) - 1
	while r > M:
		r -= L[k]
		k -= 1
		ans += 1
	print(ans, end=' ')
	L.append(l[i])
	L.sort()
	s += l[i]


(n, m) = map(int, input().split())
t = list(map(int, input().split()))
print(0, end=' ')
for i in range(1, len(t)):
	temp = sorted(t[:i])
	time = m - t[i]
	ptr = 0
	while ptr < i and time - temp[ptr] >= 0:
		time -= temp[ptr]
		ptr += 1
	print(i - ptr, end=' ')
print()


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from heapq import heapify, heappop, heappush
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
s = [i for i in l]
x = 0
f = 0
for i in range(1, n):
	s[i] += s[i - 1]
	if s[i] > m and f == 0:
		x = i
		f = 1
p = [0] * n
if f == 0:
	print(*p)
else:
	for i in range(x, n):
		if s[i - 1] > m:
			c = abs(s[i - 1] - m)
		else:
			c = s[i - 1] - m
		c += l[i]
		t = 0
		q = 0
		y = sorted(l[:i], reverse=True)
		for j in y:
			if q >= c:
				break
			q += j
			t += 1
		p[i] = t
	print(*p)


(n, M) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
ans = []
for i in range(n):
	s = M - a[i]
	b = a[:i]
	t = 0
	for j in range(i):
		if s - min(b) >= 0:
			s -= min(b)
			b.pop(b.index(min(b)))
		else:
			t += 1
			continue
	ans.append(str(t))
print(' '.join(ans))


R = lambda : map(int, input().split())
(n, m) = R()
L = list(R())
f = [0] * 101
su = 0
for i in range(n):
	su += L[i]
	p = su - m
	c = 0
	if p > 0:
		for j in reversed(range(1, 101)):
			if f[j] > 0:
				if p < f[j] * j:
					c += (p + j - 1) // j
					break
				else:
					c += f[j]
					p -= j * f[j]
	print(c, end=' ')
	f[L[i]] += 1


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = []
ma = 0
tc = [0] * (max(a) + 1)
for (i, k) in enumerate(a):
	tcm = 0
	dop = 0
	ma = m - k
	for j in range(1, len(tc)):
		if ma < tcm + tc[j] * j:
			dop += (ma - tcm) // j
			break
		else:
			tcm += tc[j] * j
			dop += tc[j]
	ans.append(i - dop)
	tc[k] += 1
print(*ans)


(n, t) = list(map(int, input().split()))
l = list(map(int, input().split()))
for i in range(n):
	pref = l[:i]
	pref.sort()
	suma = 0
	wyn = 0
	c = 1
	for j in range(i):
		suma += pref[j]
		if suma <= t - l[i]:
			wyn += 1
		else:
			c = 0
			break
	if c == 1:
		print(0)
	else:
		print(i - wyn)


from itertools import accumulate
(n, M) = map(int, input().split())
t = list(map(int, input().split()))
res = [0] * n
for i in range(n):
	tt = list(accumulate(sorted(t[:i + 1])))
	if tt[-1] > M:
		ttt = list(accumulate(sorted(t[:i], reverse=True)))
		k = 0
		while k < len(ttt):
			if tt[-1] - ttt[k] > M:
				k += 1
			else:
				break
		res[i] = k + 1
print(*res)


import bisect
(n, M) = map(int, input().split(' '))
t = list(map(int, input().split(' ')))

def find_ans(time):
	tolerate = M - time
	summa = 0
	passed = 0
	for x in prev:
		next_summa = summa + x
		if next_summa <= tolerate:
			summa = next_summa
			passed += 1
		else:
			break
	bisect.insort_left(prev, time)
	return str(len(prev) - passed - 1)
prev = []
ans = [find_ans(time) for time in t]
print(' '.join(ans))


import heapq
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
result = []
for i in range(n):
	e = a[:i]
	heapq._heapify_max(e)
	count = 0
	while sum(e) + a[i] > m:
		heapq._heappop_max(e)
		count += 1
	result.append(count)
print(' '.join(map(str, result)))


import math
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
prefix = [0] * n
count = [0] * 101
for i in range(101):
	count[i] = [0] * 200001
for i in range(n):
	prefix[i] = prefix[i - 1] + arr[i]
	for j in range(1, 101):
		count[j][i] = count[j][i - 1]
		if j == arr[i]:
			count[j][i] += 1
for i in range(n):
	if prefix[i] <= m:
		print(0, end=' ')
	else:
		ct = 0
		sm = prefix[i]
		for j in range(100, 0, -1):
			if sm - count[j][i - 1] * j > m:
				ct += count[j][i - 1]
				sm -= count[j][i - 1] * j
			else:
				ct += math.ceil((sm - m) / j)
				print(ct, end=' ')
				break


import math
import bisect
import heapq
from collections import defaultdict

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, x, y) = egcd(b % a, a)
		return (g, y - b // a * x, x)

def mulinv(b, n):
	(g, x, _) = egcd(b, n)
	if g == 1:
		return x % n

def isprime(n):
	for d in range(2, int(math.sqrt(n)) + 1):
		if n % d == 0:
			return False
	return True

def argsort(ls):
	return sorted(range(len(ls)), key=ls.__getitem__)

def f(p=0):
	if p == 1:
		return map(int, input().split())
	elif p == 2:
		return list(map(int, input().split()))
	elif p == 3:
		return list(input())
	else:
		return int(input())

class DisjointSet:

	def __init__(self, n):
		self.parent = [i for i in range(1, n + 1)]
		self.rank = [0] * (n + 1)

	def find_set(self, x):
		if self.parent[x] == x:
			return x
		else:
			self.parent[x] = self.find_set(self.parent[x])
			return self.parent[x]

	def union(self, x, y):
		set_x = self.find_set(x)
		set_y = self.find_set(y)
		if set_x != set_y:
			if self.rank[x]:
				pass

def graph(n, m, edg=False):
	edges = []
	visited = [0] * n
	g = [list() for _ in range(n + 1)]
	for i in range(m):
		(u, v) = f(1)
		g[u].append(v)
		g[v].append(u)
		if edg:
			edges.append((u, v))
	if edg:
		return (g, visited, edg)
	else:
		return (g, visited)

def bfs(g, visited):
	queue = [1]
	visited[1] = 1
	for u in queue:
		for v in g[u]:
			if visited[v] == 0:
				queue.append(v)
			visited[v] = 1

def dfs(u, g, visited):
	visited[u] = 1
	for v in g[u]:
		if visited[v] == 0:
			dfs(v, g, visited)
(n, t) = f(1)
cl = f(2)
pl = []
count = 0
sm = 0
res = []
for i in range(n):
	sm += cl[i]
	k = t - sm
	j = count - 1
	while j > -1 and k < 0:
		k += pl[j]
		j -= 1
	if k < 0:
		res.append(count)
	else:
		res.append(count - j - 1)
	bisect.insort(pl, cl[i])
	count += 1
print(*res)


from bisect import bisect_right as B
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(n):
	b = []
	for j in range(i):
		b.append(a[j])
	b.sort()
	for j in range(1, i):
		b[j] += b[j - 1]
	x = m - a[i]
	x = B(b, x)
	print(len(b) - x, end=' ')
print()


from sys import stdin, stdout
import math
import collections
(n, m) = list(map(int, stdin.readline().split()))
arr = list(map(int, stdin.readline().split()))
aux = []
for i in range(len(arr)):
	aux.sort()
	count = 0
	j = len(aux)
	while sum(aux[:j]) + arr[i] > m:
		j -= 1
		count += 1
	print(count, end=' ')
	aux.append(arr[i])


import sys
(n, M) = list(map(int, sys.stdin.readline().strip().split()))
t = list(map(int, sys.stdin.readline().strip().split()))
L = [0] * (n + 1)
x = ''
for i in range(1, n + 1):
	ans = 0
	for j in range(0, i):
		if L[j] <= M - t[i - 1]:
			ans = i - 1 - j
	L[i] = L[i - 1] + t[i - 1]
	for j in range(1, i):
		L[i - j] = min([L[i - j], L[i - j - 1] + t[i - 1]])
	x = x + str(ans) + ' '
print(x)


from heapq import heappush, heappop
(n, m) = tuple(map(int, input().rstrip().split()))
t = list(map(int, input().rstrip().split()))
times = []
total_time = 0
results = []
for i in range(0, n):
	total_time += t[i]
	skipped_students = 0
	if total_time <= m:
		heappush(times, -t[i])
		results.append(skipped_students)
	else:
		curr_total_time = total_time
		skipped_times = []
		while curr_total_time > m:
			curr_time = -heappop(times)
			skipped_times.append(curr_time)
			curr_total_time -= curr_time
			skipped_students += 1
		for tim in skipped_times:
			heappush(times, -tim)
		results.append(skipped_students)
		heappush(times, -t[i])
print(' '.join((str(x) for x in results)))


import sys
input = sys.stdin.readline

def main():
	(N, M) = map(int, input().split())
	A = list(map(int, input().split()))
	T = [0] * 101
	s = 0
	ans = []
	for a in A:
		s += a
		ss = max(s - M, 0)
		count = 0
		for t in range(100, 0, -1):
			c = T[t]
			if ss - t * c > 0:
				count += c
				ss -= t * c
			else:
				count += ss // t
				if ss % t != 0:
					count += 1
				break
		T[a] += 1
		ans.append(count)
	for a in ans:
		print(a, end=' ')
	print()
main()


order = []

def insert(val):
	i = len(order) - 1
	while i >= 0:
		if order[i] <= val:
			break
		i -= 1
	order.insert(i + 1, val)
(N, M) = list(map(int, input().split()))
t = list(map(int, input().split()))
ans = [0] * N
time = 0
for i in range(N):
	time += t[i]
	curTime = time
	if time > M:
		j = i - 1
		while curTime > M:
			curTime -= order[j]
			j -= 1
			ans[i] += 1
	insert(t[i])
print(' '.join(map(str, ans)))


from math import *
from collections import *
from itertools import *
from functools import *
from random import *

def getl(t=int):
	return [t(x) for x in input().split()]

def get(t=int):
	return t(input())
alphabet = [chr(x) for x in range(ord('a'), ord('z') + 1)]
alnum = lambda x: ord(x) - ord('a')

def main():
	(n, m) = getl()
	l = getl()
	for i in range(n):
		l1 = sorted(l[:i], reverse=True)
		ti = l[i]
		s1 = sum(l1)
		ans = 0
		for c in l1:
			if s1 + ti > m:
				s1 -= c
				ans += 1
		print(ans, end=' ')
main()


import heapq
(n, M) = map(int, input().split())
list = [int(x) for x in input().split()]
heap = []
heapq.heapify(heap)
sum = 0
for i in range(n):
	buff = []
	count = 0
	while sum + list[i] > M:
		temp = heapq.heappop(heap)
		sum += temp
		buff.append(-temp)
		count += 1
	heapq.heappush(heap, -list[i])
	sum += list[i]
	while len(buff) != 0:
		temp = buff.pop()
		sum += temp
		heapq.heappush(heap, -temp)
	print(count, end=' ')


import math
(n, m) = map(int, input().split())
c = [0 for i in range(101)]
a = input().split()
sm = 0
for i in range(n):
	x = int(a[i])
	sm += x
	cpy = sm
	ans = 0
	for j in range(100, 0, -1):
		if cpy <= m:
			break
		if c[j] == 0:
			continue
		k = min(math.ceil((cpy - m) / j), c[j])
		cpy -= k * j
		ans += k
	print(ans, sep='', end=' ')
	c[x] += 1


(a, b) = map(int, input().split())
s = [int(x) for x in input().split()]
for i in range(a):
	sc = sorted(s[:i])
	ans = 0
	thistm = sum(sc)
	while thistm + s[i] > b:
		ans += 1
		thistm -= sc.pop()
	print(ans, end=' ')


import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline

def read_int():
	return int(input())

def read_int_n():
	return list(map(int, input().strip().split()))

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

def read_str():
	return input().strip()

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

def slv(N, M, S):
	ans = []
	m = 0
	c = [0] * (max(S) + 1)
	for (i, s) in enumerate(S):
		sm = 0
		sp = 0
		m = M - s
		for j in range(1, len(c)):
			if m < sm + c[j] * j:
				sp += (m - sm) // j
				break
			else:
				sm += c[j] * j
				sp += c[j]
		ans.append(i - sp)
		c[s] += 1
	return ' '.join(map(str, ans))

def main():
	(N, M) = read_int_n()
	S = read_int_n()
	print(slv(N, M, S))
main()


(n, m) = list(map(int, input().split()))
times = list(map(int, input().split()))
ans = []
for i in range(n):
	skips = 0
	xtimes = sorted(times[:i])
	ttime = sum(xtimes) + times[i]
	while ttime > m:
		skips += 1
		ttime -= xtimes.pop()
	ans.append(skips)
print(' '.join([str(a) for a in ans]))


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
answer = [0]
students = [a[0]]
for i in range(1, n):
	students.sort(reverse=True)
	time = m - sum(students)
	counter = 0
	for item in students:
		if time >= a[i]:
			answer.append(counter)
			break
		else:
			counter += 1
			time += item
	else:
		answer.append(counter)
	students.append(a[i])
print(*answer)


(n, M) = list(map(int, input().split()))
nums = list(map(int, input().split()))
count = [0] * 101
tm = 0
for i in range(n):
	ans = 0
	tm += nums[i]
	if tm > M:
		extra = tm - M
		itr = 100
		while extra > 0:
			extra -= itr * count[itr]
			ans += count[itr]
			itr -= 1
		ans -= -extra // (itr + 1)
	print(ans)
	count[nums[i]] += 1


(n, M) = map(int, input().split())
arr = input().split()
l = []
sum_list = []
s = 0
for i in range(n):
	s += int(arr[i])
	sum_list.append(s)
	l.append(int(arr[i]))
if l[0] <= M:
	print('0', end=' ')
for i in range(1, n):
	if l[i] + sum_list[i - 1] <= M:
		print('0', end=' ')
	else:
		duplicate_l = l.copy()
		ctr = 0
		s = l[i] + sum_list[i - 1]
		while s > M:
			s -= max(duplicate_l[0:i])
			duplicate_l[duplicate_l.index(max(duplicate_l[0:i]))] = 0
			ctr += 1
		print(ctr, end=' ')


import bisect
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
s = 0
li = []
for i in range(n):
	s += arr[i]
	if s > m:
		count = 0
		k = s
		index = i - 1
		while k > m:
			k -= li[index]
			count += 1
			index -= 1
		print(count, end=' ')
	else:
		print(0, end=' ')
	x = bisect.bisect(li, arr[i])
	li.insert(x, arr[i])


import heapq
(n, M) = map(int, input().split())
M = -M
ti = list(map(int, input().split()))
ti = map(lambda i: -1 * i, ti)
li = []
ans = []
heapq.heapify(li)
summ = 0
for i in ti:
	summ += i
	ab = summ
	if summ >= M:
		heapq.heappush(li, i)
		ans.append(0)
	if summ < M:
		count = 0
		a = li.copy()
		while summ < M:
			summ -= a[0]
			count += 1
			heapq.heappop(a)
		heapq.heappush(li, i)
		summ = ab
		ans.append(count)
print(*ans)


x_ = input().split()
x = [int(d) for d in x_]
y_ = input().split()
y = [int(d) for d in y_]
total_time = x[1]
ans = []
for i in range(x[0]):
	if sum(y[:i + 1]) <= total_time:
		ans.append(0)
	elif sum(y[:i + 1]) > total_time:
		u = y[:i]
		u.sort(reverse=True)
		j = 0
		k = 0
		while sum(y[:i + 1]) - sum(u[:j]) > total_time:
			j = j + 1
			k = k + 1
		ans.append(k)
print(*ans)


import atexit
import io
import sys
import bisect
_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B

@atexit.register
def write():
	sys.__stdout__.write(_O_B.getvalue())

def main():
	(n, m) = map(int, input().split())
	t = list(map(int, input().split()))
	s = []
	su = 0
	for i in t:
		su += i
		if su > m:
			f = 0
			tsu = su
			idx = len(s) - 1
			while tsu > m:
				f += 1
				tsu -= s[idx]
				idx -= 1
			print(f, end=' ')
		else:
			print(0, end=' ')
		bisect.insort(s, i)
	print()
main()


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
cnt = [0] * 101
curr = 0
for i in range(n):
	tm = m - a[i]
	ans = 0
	for j in range(1, 101):
		tmp = int(tm / j)
		if tmp >= cnt[j]:
			tm -= cnt[j] * j
			ans += cnt[j]
		else:
			tm -= tmp * j
			ans += tmp
	print(i - ans, end=' ')
	cnt[a[i]] += 1


import math
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [a[0]]
for i in a[1:]:
	b.append(b[-1] + i)
ans = [0]
c = [0] * 101
c[a[0]] = 1
for i in range(1, n):
	s = b[i]
	j = 100
	an = 0
	while s > m:
		if s - j * c[j] >= m:
			s -= j * c[j]
			an += c[j]
		else:
			an += math.ceil((s - m) / j)
			s = m
		j -= 1
	c[a[i]] += 1
	ans.append(an)
print(*ans)


info = input()
info = info.split(' ')
m = int(info[1])
ts = input()
ts = ts.split(' ')
sum1 = 0
for i in range(0, int(info[0])):
	sr = [int(x) for x in ts[0:i]]
	deleted = 0
	sr.sort()
	sum1 += int(ts[i])
	sum2 = sum1
	while sum2 > m:
		sum2 -= sr[len(sr) - 1]
		sr.remove(sr[len(sr) - 1])
		deleted += 1
	sr.append(int(ts[i]))
	print(deleted)


(n, M) = map(int, input().split())
L = list(map(int, input().split()))
s = 0
for i in range(0, n):
	br = 0
	s = s + L[i]
	sc = s
	Lc = L[:]
	if s <= M:
		print(br, end=' ')
	else:
		b2 = 0
		while s > M:
			s = s - max(L[0:i - b2])
			L.remove(max(L[0:i - b2]))
			br += 1
			b2 += 1
		print(br, end=' ')
	s = sc
	L = Lc[:]


(n, M) = map(int, input().split())
l = list(map(int, input().split()))
r = [0]
for i in range(1, len(l)):
	t = M
	l[:i] = sorted(l[:i])
	t -= l[i]
	sum = 0
	for j in range(i):
		t -= l[j]
		if t >= 0:
			sum += 1
		else:
			break
	r.append(i - sum)
for i in r:
	print(i, end=' ')


import sys
from os import path
if path.exists('input.txt') and path.exists('output.txt'):
	sys.stdout = open('output.txt', 'w')
	sys.stdin = open('input.txt', 'r')

def main():
	(n, m) = (int(i) for i in input().split())
	times = [int(i) for i in input().split()]
	for i in range(n):
		sliced = times[:i]
		sm = sum(sliced) + times[i]
		if sm <= m:
			print(0, end=' ')
		else:
			ans = 0
			sliced.sort(reverse=True)
			for sl in sliced:
				sm -= sl
				ans += 1
				if sm <= m:
					print(ans, end=' ')
					break
main()


(a, b) = list(map(int, input().split()))
l = list(map(int, input().split()))
ans = [0]
for i in range(len(l)):
	ans.append(l[i] + ans[-1])
i = 0
n_ans = []
ans.pop(0)
while i < a:
	if ans[i] <= b:
		n_ans.append(0)
	else:
		l[0:i] = sorted(l[0:i])
		tar = ans[i]
		c = 0
		while tar > b:
			c += 1
			tar -= l[i - c]
		n_ans.append(c)
	i += 1
print(*n_ans)


(n, M) = list(map(int, input().strip().split()))
t = list(map(int, input().strip().split()))
res = []
for i in range(n):
	l = t.copy()
	l = l[:i]
	l.sort()
	l = l[::-1]
	j = 0
	while M - t[i] - sum(l[j:]) < 0:
		j += 1
	res.append(str(j))
print(' '.join(res))


(n, M) = map(int, input().split())
t = list(map(int, input().split()))
f = [0 for _ in range(101)]
a = []
for i in range(n):
	Mi = M - t[i]
	c = 0
	for j in range(1, 101):
		k = min(Mi // j, f[j])
		Mi -= k * j
		c += k
	a.append(i - c)
	f[t[i]] += 1
print(' '.join(map(str, a)))


(n, m) = list(map(int, input().split()))
t = list(map(int, input().split()))
for i in range(n):
	a = sorted(t[:i])
	s = sum(a) + t[i]
	c = 0
	while s > m:
		s -= a.pop(-1)
		c += 1
	print(c, end=' ')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = []
sumi = 0
for i in range(n):
	sumi = sum(a[:i + 1])
	co = 0
	temp = a[:i]
	while sumi > m:
		co += 1
		sumi = sumi - max(temp)
		temp.remove(max(temp))
	ans.append(co)
print(*ans)


(n, m) = (int(x) for x in input().split())
tests = [int(x) for x in input().split()]
su = 0
output = []
for i in range(n):
	su += tests[i]
	if su <= m:
		output.append(0)
	else:
		newi = i
		counter = 0
		newsu = su
		tests1 = tests[:i]
		tests1.sort()
		while newsu > m:
			newi -= 1
			newsu -= tests1[newi]
			counter += 1
		output.append(counter)
out = ''
for i in output:
	out += str(i) + ' '
out = out[:-1]
print(out)


from itertools import *
from math import *
from collections import *
from heapq import *
from bisect import bisect_left, bisect_right
from copy import deepcopy
inf = float('inf')
mod = 10 ** 9 + 7
from functools import reduce
import sys
sys.setrecursionlimit(10 ** 7)
(n, M) = map(int, input().split())
t = list(map(int, input().split()))
h = []
(sum, a) = (0, 0)
ans = []
for i in range(n):
	if sum - t[i] >= -M:
		ans.append(0)
		heappush(h, -t[i])
		sum -= t[i]
	else:
		h1 = deepcopy(h)
		heapify(h1)
		a = 0
		sum1 = sum
		while sum1 - t[i] < -M:
			b = heappop(h1)
			sum1 -= b
			a += 1
		ans.append(a)
		heappush(h, -t[i])
		sum -= t[i]
print(*ans, sep=' ')


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = [0] * n
pre = [0] * n
pre[0] = a[0]
for i in range(1, n):
	pre[i] = pre[i - 1] + a[i]
aux = []
aux.append(a[0])
for i in range(1, n):
	if pre[i] > m:
		temp = pre[i]
		count = 0
		aux.sort()
		j = len(aux) - 1
		while temp > m:
			temp = temp - aux[j]
			j = j - 1
			count = count + 1
		ans[i] = count
	aux.append(a[i])
for i in ans:
	print(i, end=' ')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(RL())

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)

def toord(c):
	return ord(c) - ord('a')

def lcm(a, b):
	return a * b // gcd(a, b)
mod = 998244353
INF = float('inf')
from math import factorial, sqrt, ceil, floor, gcd
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	(n, m) = RL()
	arr = RLL()
	sm = [0]
	rec = [0] * 101
	for i in range(n):
		sm.append(sm[-1] + arr[i])
	res = []
	for i in range(1, n + 1):
		if sm[i] <= m:
			res.append(0)
		else:
			now = sm[i]
			tmp = 0
			dif = now - m
			for j in range(100, 0, -1):
				if rec[j] == 0:
					continue
				num = rec[j]
				use = min(num, ceil(dif / j))
				tmp += use
				dif -= use * j
				if dif <= 0:
					break
			res.append(tmp)
		rec[arr[i - 1]] += 1
	print(*res)
main()


inp = list(map(int, input().split()))
t = inp[1]
inp = list(map(int, input().split()))
l = []
for i in range(1, len(inp) + 1):
	l.append(sum(inp[:i]))
for i in range(len(l)):
	if l[i] < t:
		print(0, end=' ')
	else:
		k = l[i] - t
		j = inp[:i]
		j.sort(reverse=True)
		sumi = 0
		count = 0
		p = 0
		while sumi < k:
			sumi = sumi + j[count]
			count += 1
		print(count, end=' ')


def fail_student(n, m, l):
	d = []
	for i in range(n):
		k = sorted(l[:i])
		s = sum(k)
		j = 0
		while s + l[i] > m:
			s -= k.pop()
			j += 1
		d.append(j)
	return d
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
print(*fail_student(n, m, l))


from copy import copy
(n, m) = map(int, input().split())
T = list(map(int, input().split()))
Z = copy(T)
for i in range(1, n):
	Z[i] += Z[i - 1]
for i in range(n):
	if Z[i] <= m:
		print(0, end=' ')
	else:
		A = T[:i]
		A.sort()
		s = 0
		for j in range(len(A)):
			s += A[j]
			if s > m - T[i]:
				print(len(A) - j, end=' ')
				break


R = lambda : map(int, input().split())
(n, m) = R()
a = [0, 101]
for t in R():
	s = i = 0
	while s + t <= m:
		s += a[i]
		i += 1
	j = len(a)
	print(j - i)
	while a[j - 1] > t:
		j -= 1
	a.insert(j, t)


(N, M) = map(int, input().split())
A = [int(a) for a in input().split()]
ANS = []
X = []
t = 0
for i in range(N):
	tt = t
	j = 0
	while A[i] > M - tt:
		tt -= X[j]
		j += 1
	ANS.append(j)
	X = sorted(X + [A[i]])[::-1]
	t += A[i]
print(*ANS)


(m, M) = map(int, input().split())
arr = list(map(int, input().split()))
res = [0] * m
sm = arr[0]
cnt = 0
curr = [arr[0]]
for i in range(1, m):
	temp = M - sm
	if arr[i] <= M - sm:
		sm += arr[i]
		curr.append(arr[i])
		curr.sort(reverse=True)
	else:
		k = 0
		cnt = 0
		sm2 = sm
		while arr[i] > M - sm2:
			sm2 -= curr[k]
			cnt += 1
			k += 1
		sm += arr[i]
		curr.append(arr[i])
		curr.sort(reverse=True)
	res[i] = cnt
print(*res)


def getN():
	return int(input())

def getList():
	return list(map(int, input().split()))
(n, m) = getList()
nums = getList()

def solve(nums, m, i):
	tgt = nums[i]
	queue = nums[:i]
	queue.sort()
	for (idx, q) in enumerate(queue):
		tgt += q
		if tgt > m:
			return i - idx
	return 0
answers = []
for i in range(n):
	answers.append(solve(nums, m, i))
print(' '.join(list(map(str, answers))))


(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
pre = [arr[0]]
for i in range(1, n):
	pre.append(pre[-1] + arr[i])
ans = []
freq = [0 for i in range(105)]
for i in range(n):
	if pre[i] <= m:
		ans.append(0)
	else:
		x = pre[i]
		cnt = 0
		d = x - m
		for j in range(104, 0, -1):
			if freq[j] > 0:
				if freq[j] * j <= d:
					d -= j * freq[j]
					cnt += freq[j]
				elif d % j == 0:
					y = d // j
					cnt += y
					d = 0
				else:
					y = d // j + 1
					cnt += y
					d = 0
			if d == 0:
				break
		ans.append(cnt)
	freq[arr[i]] += 1
print(*ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = []
qw = []
for i in range(len(a)):
	b.append(a[i])
	q = []
	for j in range(len(b) - 1):
		q.append(b[j])
	c = 0
	q.sort()
	q.insert(0, a[i])
	while sum(q) > m:
		q.pop()
		c = c + 1
	qw.append(c)
for i in range(len(qw)):
	print(qw[i], end=' ')


(n, m) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
sum_here = 0
for i in range(n):
	sum_here += arr[i]
	j = p = 0
	sh = sum_here
	el = sorted(arr[:i], reverse=True)
	while sh > m:
		sh -= el[j]
		p += 1
		j += 1
	print(p, end=' ')


(n, m) = map(int, input().split())
t = list(map(int, input().split()))
ans = []
for i in range(n):
	if sum(t[:i + 1]) <= m:
		ans.append(0)
	else:
		remain = sum(t[:i + 1]) - m
		fail_student = sorted(t[:i], reverse=True)
		for j in range(i):
			remain -= fail_student[j]
			if remain <= 0:
				ans.append(j + 1)
				break
print(' '.join(map(str, ans)))


def ri():
	return [int(i) for i in input().split()]

def fl(a, b):
	return abs(a - b)

def main(n, m, t):
	if m >= t[0]:
		print(0, end=' ')
	else:
		print(1, end=' ')
	for i in range(1, len(t)):
		if i == 4:
			asddd = 1
			pass
		new = t[:i]
		new.sort()
		mt = m
		ans = 0
		sm = sum(new)
		while mt < sm + t[i]:
			sm -= new.pop()
			ans += 1
		print(ans, end=' ')
(n, m) = ri()
t = ri()
main(n, m, t)


(n, M) = map(int, input().split())
ls = list(map(int, input().split()))
count = {}
for i in range(1, 101):
	count[i] = 0
for i in range(n):
	Sum = ls[i]
	cnt = 1
	flag = 0
	for j in range(1, 101):
		if Sum + j * count[j] > M:
			break
		Sum += j * count[j]
		cnt += count[j]
	else:
		flag = 1
	if flag == 0:
		cnt += (M - Sum) // j
		Sum += j * ((M - Sum) // j)
	count[ls[i]] += 1
	print(i + 1 - cnt, end=' ')
print()


from itertools import accumulate
from collections import Counter
from bisect import bisect as br, bisect_left as bl

class PMS:

	def __init__(self, A, B, issum=False):
		(self.X, self.comp) = self.compress(B)
		self.size = len(self.X)
		self.tree = [0] * (self.size + 1)
		self.p = 2 ** (self.size.bit_length() - 1)
		self.dep = self.size.bit_length()
		CA = Counter(A)
		S = [0] + list(accumulate([CA[self.X[i]] for i in range(self.size)]))
		for i in range(1, 1 + self.size):
			self.tree[i] = S[i] - S[i - (i & -i)]
		if issum:
			self.sumtree = [0] * (self.size + 1)
			Ssum = [0] + list(accumulate([CA[self.X[i]] * self.X[i] for i in range(self.size)]))
			for i in range(1, 1 + self.size):
				self.sumtree[i] = Ssum[i] - Ssum[i - (i & -i)]

	def compress(self, L):
		L2 = list(set(L))
		L2.sort()
		C = {v: k for (k, v) in enumerate(L2, 1)}
		return (L2, C)

	def leng(self):
		return self.count(self.X[-1])

	def count(self, i):
		i = self.comp[i]
		s = 0
		while i > 0:
			s += self.tree[i]
			i -= i & -i
		return s

	def less(self, v):
		i = bl(self.X, v)
		s = 0
		while i > 0:
			s += self.tree[i]
			i -= i & -i
		return s

	def leq(self, v):
		i = br(self.X, v)
		s = 0
		while i > 0:
			s += self.tree[i]
			i -= i & -i
		return s

	def add(self, i, x):
		i = self.comp[i]
		while i <= self.size:
			self.tree[i] += x
			i += i & -i

	def get(self, v):
		if v <= 0:
			return -1
		s = 0
		k = self.p
		for _ in range(self.dep):
			if s + k <= self.size and self.tree[s + k] < v:
				s += k
				v -= self.tree[s]
			k //= 2
		return self.X[s]

	def gets(self, v):
		v1 = v
		if v <= 0:
			return 0
		s = 0
		k = self.p
		for _ in range(self.dep):
			if s + k <= self.size and self.sumtree[s + k] < v:
				s += k
				v -= self.sumtree[s]
			k //= 2
		if s == self.size:
			return self.leng()
		return self.count(self.X[s]) + (v1 - self.countsum(self.X[s])) // self.X[s]

	def addsum(self, i, x):
		self.add(i, x)
		x *= i
		i = self.comp[i]
		while i <= self.size:
			self.sumtree[i] += x
			i += i & -i

	def countsum(self, i):
		i = self.comp[i]
		s = 0
		while i > 0:
			s += self.sumtree[i]
			i -= i & -i
		return s

	def getsum(self, v):
		x = self.get(v)
		return self.countsum(x) - x * (self.count(x) - v)
(N, M) = map(int, input().split())
T = list(map(int, input().split()))
S = PMS([T[0]], T, True)
print(0)
for i in range(1, N):
	print(i - S.gets(M - T[i]))
	S.addsum(T[i], 1)


a = []
total = 0

def binary_search(n, l):
	first = 0
	last = len(l) - 1
	found = False
	mid = (first + last) // 2
	while first <= last and (not found):
		mid = (first + last) // 2
		if l[mid] == n:
			found = True
		elif n < l[mid]:
			last = mid - 1
		else:
			first = mid + 1
	if found:
		return mid
	else:
		return first
(n, M) = map(int, input().split())
t = [int(x) for x in input().split()]
a = []
total = 0
lena = 0
for i in range(n):
	if total + t[i] <= M:
		if i <= lena:
			print('0', end=' ')
		else:
			print(i - lena, end=' ')
		a.insert(binary_search(t[i], a), t[i])
		lena += 1
		total += t[i]
	else:
		compare = total + t[i] - M
		s = 0
		count = 0
		for j in range(lena - 1, -1, -1):
			if s < compare:
				s += a[j]
				count += 1
			else:
				break
		print(count + i - lena, end=' ')
		if t[i] < a[lena - 1]:
			total -= a.pop(lena - 1)
			a.insert(binary_search(t[i], a), t[i])
			total += t[i]


(n, d) = map(int, input().split())
l = list((int(i) for i in input().split()))
m = []
sum = 0
for i in l:
	sum += i
	m.append(sum)
k = []
for i in range(len(m)):
	if m[i] <= d:
		k.append(0)
	else:
		alig = l[:i]
		su = m[i]
		alig.sort(reverse=True)
		count = 0
		for j in alig:
			su -= j
			if su <= d:
				count += 1
				k.append(count)
				break
			else:
				count += 1
print(' '.join(map(str, k)))


(n, M) = list(map(int, input().split(' ')))
time = list(map(int, input().split()))
ans_list = []
for a in range(n):
	leave = 0
	time_reql = time[:a + 1]
	time_req = sum(time_reql)
	time_sort = time_reql[:-1]
	time_sort.sort(reverse=True)
	while time_req > M:
		time_req = time_req - time_sort[leave]
		leave = leave + 1
	ans_list.append(str(leave))
ans = ' '.join(ans_list)
print(ans)


def Terentii(T, n, s):
	k = 0
	while T > n:
		T -= max(s)
		del s[s.index(max(s))]
		k += 1
	return k
n = []
s = []
n = list(map(int, input().split()))
s = list(map(int, input().split()))
F = ''
for i in range(1, n[0] + 1):
	T = 0
	for j in range(i):
		T += s[j]
	F += str(Terentii(T, int(n[1]), s[0:i - 1])) + ' '
print(F)


def factorial(n):
	if n == 1:
		return 1
	if n == 0:
		return 1
	return n * factorial(n - 1)

def cnk(n, k):
	if k > n:
		return 0
	return factorial(n) / (factorial(n - k) * factorial(k))

def main():
	(n, m) = map(int, input().split())
	students = list(map(int, input().split()))
	for i in range(len(students)):
		count = 0
		cur_stud = students[:i]
		cur_stud.sort()
		while students[i] + sum(cur_stud) > m:
			count += 1
			cur_stud.pop()
		print(count, end=' ')
main()


(n, M) = map(int, input().split())
arr = list(map(int, input().split()))
for i in range(n):
	cnt = sum(arr[:i + 1])
	tmp = arr[:i]
	tmp.sort()
	tmp = tmp[::-1]
	if len(tmp) == 0:
		print(0, end=' ')
	else:
		j = 0
		while cnt > M:
			cnt -= tmp[j]
			j += 1
		print(j, end=' ')


import heapq
(n, M) = map(int, input().split())
ts = map(int, input().split())
minh = []
maxh = []
s = 0
for t in ts:
	while s + t > M:
		e = -1 * heapq.heappop(maxh)
		heapq.heappush(minh, e)
		s -= e
	while minh and minh[0] + s + t <= M:
		e = heapq.heappop(minh)
		heapq.heappush(maxh, -1 * e)
		s += e
	print(len(minh), end=' ')
	if maxh and t <= -1 * maxh[0]:
		heapq.heappush(maxh, -1 * t)
		s += t
	elif minh and t >= minh[0]:
		heapq.heappush(minh, t)
	else:
		heapq.heappush(maxh, -1 * t)
		s += t


(n, m) = list(map(int, input().split()))
h = list(map(int, input().split()))
p = []
d = []
d.append(0)
for i in range(1, n):
	p.append(h[i - 1])
	p.sort()
	k = sum(p)
	l = 0
	while k + h[i] > m:
		k -= p[len(p) - 1 - l]
		l += 1
	d.append(l)
print(*d)


(n, m) = list(map(int, input().split()))
A = [int(x) for x in input().split()]
R = []
S = []
for a in A:
	s = sum(S)
	i = len(S)
	while s + a > m:
		i -= 1
		s -= S[i]
	R.append(len(S) - i)
	S.append(a)
	S.sort()
print(*R)


import heapq
(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
sum = 0
for q in range(len(arr)):
	sum += arr[q]
	count = 0
	new = list(arr[:q])
	new.sort(reverse=True)
	temp = 0
	if sum - temp > m:
		for w in new:
			temp += w
			count += 1
			if sum - temp <= m:
				break
	print(count)


def check(list, time, n):
	times = [0] * 101
	count = 0
	l = []
	for i in range(n):
		count += list[i]
		if count > time:
			count1 = 0
			check = count
			(j, z) = (100, True)
			while j >= 0 and z:
				if times[j] != 0:
					(m, x) = (times[j], True)
					k = 0
					while k < m and x:
						check -= j
						count1 += 1
						if check <= time:
							(x, z) = (False, False)
						k += 1
					j -= 1
				else:
					j -= 1
			l.append(count1)
		else:
			l.append(0)
		times[list[i]] += 1
	return l
m = list(map(int, input().strip().split()))
l = list(map(int, input().strip().split()))
print(' '.join((str(x) for x in check(l, m[1], m[0]))))


import heapq as hp
import sys
input = sys.stdin.readline
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
q = []
s = 0
ans = []
for a in A:
	qq = q[:]
	hp.heappush(q, -a)
	s += a
	c = 0
	ss = s
	while ss > M:
		b = -hp.heappop(qq)
		ss -= b
		c += 1
	ans.append(c)
for a in ans:
	print(a, end=' ')
print()


nM = input().split()
n = int(nM[0])
M = int(nM[1])
total_minutes = input().split()
for i in range(n):
	total_minutes[i] = int(total_minutes[i])
for i in range(n):
	count = 0
	count_minutes = sum(total_minutes[:i]) + total_minutes[i]
	if count_minutes > M:
		j = i
		sorted_count_minutes = sorted(total_minutes[:j])
		while sum(sorted_count_minutes) + total_minutes[i] > M:
			j -= 1
			sorted_count_minutes = sorted(sorted_count_minutes[:j])
			count += 1
	print(count, end=' ')


def partition(arr, low, high):
	i = low - 1
	pivot = arr[high]
	for j in range(low, high):
		if arr[j] <= pivot:
			i = i + 1
			(arr[i], arr[j]) = (arr[j], arr[i])
	(arr[i + 1], arr[high]) = (arr[high], arr[i + 1])
	return i + 1

def quickSort(arr, low, high):
	if low < high:
		pi = partition(arr, low, high)
		quickSort(arr, low, pi - 1)
		quickSort(arr, pi + 1, high)

def ret(t, i, val):
	quickSort(t, 0, i - 1)
	ret = 0
	for k in range(0, i):
		if t[k] <= val:
			val -= t[k]
		else:
			ret += 1
	return ret
(n, m) = input().split(' ')
n = int(n)
m = int(m)
t = list(map(int, input().split(' ')))
a = [0] * n
for i in range(n):
	if i == 0:
		if t[0] <= m:
			a[0] = 0
	else:
		a[i] = ret(t, i, m - t[i])
for x in range(0, n):
	print(a[x], end=' ')


from heapq import *
(n, m) = map(int, input().split())
t = [int(x) for x in input().split()]
cnt = [0] * 101
mx = [0] * 101
res = []
ct = 0
for i in range(n):
	if ct + t[i] <= m:
		res.append('0')
	else:
		nd = m - t[i]
		rem = 0
		for j in range(1, 101):
			if nd >= mx[j]:
				nd -= mx[j]
				rem += cnt[j]
			else:
				rem += nd // j
				nd = 0
			if nd == 0:
				break
		res.append(str(i - rem))
	cnt[t[i]] += 1
	mx[t[i]] += t[i]
	ct += t[i]
print(' '.join(res))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = []
for i in range(n):
	s = sum(a[:i + 1])
	if s <= m:
		ans.append(0)
	else:
		count = 0
		k = set()
		c = sorted(a[:i])
		while s > m:
			x = c.pop()
			s -= x
			count += 1
		ans.append(count)
print(' '.join(map(str, ans)))


(n, t) = map(int, input().split())
arr = [0] * 101
students = [int(x) for x in input().split()]
cur_time = 0
for i in students:
	cur_time += i
	ptr = 100
	this = cur_time
	acc = 0
	while ptr:
		if this - arr[ptr] * ptr <= t:
			acc += (this - t - 1) // ptr + 1
			break
		else:
			acc += arr[ptr]
			this -= arr[ptr] * ptr
		ptr -= 1
	print(max(0, acc), end=' ')
	arr[i] += 1


(n, m) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
ans = [0] * n
curr_sum = 0
for i in range(len(arr)):
	curr_sum += arr[i]
	if curr_sum > m:
		c = 0
		temp = curr_sum
		sub = sorted(arr[:i])
		for j in range(i - 1, -1, -1):
			temp -= sub[j]
			c += 1
			if temp <= m:
				break
		ans[i] = c
	else:
		ans[i] = 0
print(*ans)


from bisect import insort_left as bl
import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
su = 0
for i in range(n):
	su += a[i]
	if su > m:
		arr = a[:i]
		arr = sorted(arr, reverse=True)
		suh = su
		t = 0
		while suh > m:
			suh -= arr[t]
			t += 1
		print(t, end=' ')
	else:
		print(0, end=' ')


def ri():
	return [int(i) for i in input().split()]

def fl(a, b):
	return abs(a - b)

def gt_mx(d, l):
	ans = 0
	for i in reversed(range(1, 110)):
		if l < 0:
			break
		if d[i] > 0:
			do = min(l // i, d[i])
			ans += do
			l -= do * i
			if l > 0 and do < d[i]:
				l -= i
				ans += 1
	return ans

def main(n, m, t):
	if m >= t[0]:
		print(0, end=' ')
	else:
		print(1, end=' ')
	d = {i: 0 for i in range(1, 110)}
	d[t[0]] += 1
	sm = t[0]
	for i in range(1, len(t)):
		sm += t[i]
		if i == 5:
			asd = 123
		if sm > m:
			delit = gt_mx(d, sm - m)
			print(delit, end=' ')
		else:
			print(0, end=' ')
		d[t[i]] += 1
(n, m) = ri()
t = ri()
main(n, m, t)


t = list(map(int, input().split(' ')))
n = t[0]
m = t[1]
t = list(map(int, input().split(' ')))
s = []
ans = []
q = 0
for i in range(n):
	q = q + t[i]
	z = q
	if q <= m:
		ans.append(0)
	else:
		a = t[:i]
		a.sort(reverse=True)
		j = 0
		c = 0
		while z > m:
			z = z - a[j]
			j += 1
			c += 1
		ans.append(c)
for i in range(n):
	print(ans[i], end=' ')


import bisect
(n, M) = map(int, input().split())
nums = [int(x) for x in input().split()]
cum = []
res = []
seen = []
for i in nums:
	if len(cum) == 0:
		cum.append(i)
		seen.append(i)
		res.append(0)
	else:
		rem = M - i
		pos = bisect.bisect(cum, rem)
		res.append(len(cum) - pos)
		inpos = bisect.bisect(seen, i)
		bisect.insort(seen, i)
		if inpos == 0:
			cum = [i] + [x + i for x in cum]
		else:
			cum = cum[:inpos] + [i + cum[inpos - 1]] + [x + i for x in cum[inpos:]]
resstr = ' '.join([str(x) for x in res])
print(resstr)


from sys import stdin, stdout
import math
import collections
(n, m) = list(map(int, stdin.readline().split()))
arr = list(map(int, stdin.readline().split()))
aux = dict()
for i in range(1, 101):
	aux[i] = 0
cur_sum = 0
for i in range(len(arr)):
	count = 0
	if cur_sum + arr[i] <= m:
		count = 0
	else:
		temp = 0
		for k in range(100, 0, -1):
			temp += k * aux[k]
			if cur_sum - temp + arr[i] <= m:
				temp -= k * aux[k]
				start = 1
				end = aux[k]
				while True:
					if start >= end:
						if cur_sum - temp - (start - 1) * k + arr[i] <= m:
							start -= 1
							break
						break
					mid = (start + end) // 2
					if cur_sum - mid * k - temp + arr[i] <= m:
						end = mid - 1
					else:
						start = mid + 1
				if cur_sum - start * k - temp + arr[i] <= m:
					count += start
					break
				else:
					count += start + 1
					break
			else:
				count += aux[k]
	cur_sum += arr[i]
	print(count, end=' ')
	aux[arr[i]] += 1


(n, M) = [int(x) for x in input().split()]
t = [int(x) for x in input().split()]
d = {}
res = [0 for x in range(len(t))]
sum = 0
for i in range(len(t)):
	if sum + t[i] <= M:
		if d.__contains__(t[i]) == False:
			d[t[i]] = 1
		else:
			d[t[i]] = d[t[i]] + 1
		sum += t[i]
		res[i] = 0
	else:
		tmp_sum = sum
		tmp_ans = 0
		for key in sorted(d.keys(), reverse=True):
			if tmp_sum - d[key] * key + t[i] <= M:
				if (tmp_sum + t[i] - M) % key == 0:
					cnt = int((tmp_sum + t[i] - M) / key)
				else:
					cnt = round(float(tmp_sum + t[i] - M) / key + 0.5)
				tmp_ans += cnt
				break
			else:
				tmp_sum -= d[key] * key
				tmp_ans += d[key]
		if d.__contains__(t[i]) == False:
			d[t[i]] = 1
		else:
			d[t[i]] = d[t[i]] + 1
		sum += t[i]
		res[i] = tmp_ans
print(*res, sep=' ')


def main():
	(n, M) = map(int, input().split())
	ts = [int(v) for v in input().split()]
	for i in range(n):
		if sum(ts[:i + 1]) <= M:
			print(0)
			continue
		passed = ts[:i]
		passed.sort()
		sum_ = sum(passed) + ts[i]
		count = 0
		while sum_ > M:
			sum_ -= passed[-(count + 1)]
			count += 1
		print(count)
main()


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
sas = s.copy()
g = 0
ans = []
for i in range(1, len(s)):
	s[i] += s[i - 1]
h = [0 for i in range(101)]
for i in range(len(s)):
	g = 0
	if s[i] <= m:
		ans.append(0)
	else:
		posos = s[i] - m
		for j in range(100, -1, -1):
			if h[j] * j >= posos:
				ans.append((posos + j - 1) // j + g)
				break
			elif h[j] > 0:
				g += h[j]
				posos -= h[j] * j
	h[sas[i]] += 1
print(*ans)


(n, M) = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * 110
for x in a:
	cc = 0
	cur = 0
	for j in range(1, 101):
		h = min((M - x - cur) // j, b[j])
		cc += h
		cur += h * j
	b[x] += 1
	print(sum(b) - cc - 1)


(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
res = [0]
for i in range(1, n):
	s = arr[i]
	temp = sorted(arr[:i])
	cnt = 0
	for j in temp:
		if s > m:
			break
		cnt += 1
		s += j
	if s <= m:
		res.append(0)
	else:
		res.append(i - cnt + 1)
print(*res)


import sys
inf = float('inf')
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()

def int1():
	return int(input())
import string
import math
from itertools import combinations

def main():
	(n, k) = get_array()
	a = get_array()
	b = []
	for i in a:
		b.append(i)
	s = 0
	i = 0
	l = []
	while i < len(a):
		s = s + a[i]
		if s <= k:
			l.append(a[i])
			a[i] = 0
		i = i + 1
	l.sort(reverse=True)
	i = 0
	while i < n:
		if a[i] != 0:
			m = 0
			s1 = sum(b[:i + 1])
			j = 0
			y1 = 0
			while j < len(l):
				m = m + l[j]
				if s1 - m > k:
					y1 = y1 + 1
				if s1 - m <= k:
					y1 = y1 + 1
					break
				j = j + 1
			a[i] = y1
			l.append(b[i])
			l.sort(reverse=True)
		i = i + 1
	print(*a)
main()


import bisect
(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
answer = []
students = [0] * 100
for i in range(n):
	time = m - a[i]
	counter = 0
	for j in range(100):
		x = min(time // (j + 1), students[j])
		counter += x
		time -= x * (j + 1)
	answer.append(i - counter)
	students[a[i] - 1] += 1
print(*answer)


(n, m) = map(int, input().split())
t = list(map(int, input().split()))
sums = [t[0]] * n
print(0, end=' ')
for i in range(1, n):
	sums[i] = sums[i - 1] + t[i]
	diff = 0
	if sums[i] > m:
		tmp_sum = sums[i]
		while tmp_sum > m:
			diff += 1
			tmp_sum -= t[i - diff]
	print(diff, end=' ')
	t[:i + 1] = sorted(t[:i + 1])


(n, total) = map(int, input().split())
time = list(map(int, input().split()))
final = [0]
new = [time[0]]
till_now = time[0]
for i in range(1, n):
	till_now += time[i]
	if till_now <= total:
		final.append(0)
	else:
		new.sort(reverse=True)
		count = 0
		pres = till_now
		while pres > total:
			pres -= new[count]
			count += 1
		final.append(count)
	new.append(time[i])
for q in final:
	print(q, end=' ')
print()


import heapq
(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
pre = [arr[0]]
for i in range(1, n):
	pre.append(pre[-1] + arr[i])
ans = []
temp = []
for i in range(n):
	if pre[i] <= m:
		ans.append(0)
	else:
		rem = temp[:]
		rem.sort()
		x = pre[i]
		cnt = 0
		for j in range(len(rem) - 1, -1, -1):
			x = x - rem[j]
			cnt += 1
			if x <= m:
				break
		ans.append(cnt)
	temp.append(arr[i])
print(*ans)


(n, M) = map(int, input().split())
t = [int(z) for z in input().split()]
for i in range(n):
	r = 0
	a = sorted(t[:i])
	b = t[i]
	while sum(a) + b > M:
		a.pop(-1)
		r += 1
	print(r, end=' ')


(X, Students) = (list(map(int, input().split())), list(map(int, input().split())))
for i in range(X[0]):
	(Count, Temp, Sum) = (0, X[1], sum(Students[:i]) + Students[i])
	if Sum <= X[1]:
		print(0, end=' ')
		continue
	else:
		STemp = sorted(Students[:i], reverse=True)
		for j in range(i):
			if X[1] >= Sum:
				break
			(Count, Sum) = (Count + 1, Sum - STemp[j])
	print(Count, end=' ')


def mp():
	return map(int, input().split())
(n, m) = mp()
a = list(mp())
s = [0] * (n + 1)
for i in range(n):
	s[i] = s[i - 1] + a[i]
cnt = [0] * 101
for i in range(n):
	ans = 0
	t = s[i]
	while t > m:
		for j in range(100, 0, -1):
			if cnt[j] != 0:
				k = max(0, (t - m + j - 1) // j)
				ans += min(k, cnt[j])
				t -= min(k, cnt[j]) * j
	cnt[a[i]] += 1
	print(ans, end=' ')


(n, m) = map(int, input().split())
qw = [int(i) for i in input().split()]
lk = []
lk.append(0)
b = 0
lki = []

def insert(arr, elem):
	if len(arr) >= 110:
		if arr[-1] >= elem:
			return
		arr[-1] = elem
	else:
		arr.append(elem)
	for i in range(len(arr) - 1, 0, -1):
		if arr[i] > arr[i - 1]:
			(arr[i], arr[i - 1]) = (arr[i - 1], arr[i])
for i in range(1, n):
	b += qw[i - 1]
	insert(lki, qw[i - 1])
	if m >= b + qw[i]:
		lk.append(0)
		continue
	z = 0
	rest = b + qw[i] - m
	for u in range(len(lki)):
		z += lki[u]
		if rest <= z:
			lk.append(u + 1)
			break
print(*lk)


(n, m) = list(map(int, input().split()))
array = list(map(int, input().split()))
res = []

def sumWithout(mas, indexes):
	res = 0
	for i in range(len(mas)):
		if not i in indexes:
			res += mas[i]
	return res

def maxWithout(mas, indexes):
	res = -1
	resInd = 0
	for i in range(len(mas)):
		if not i in indexes and res < mas[i]:
			res = mas[i]
			resInd = i
	return resInd
prev = []
for t in array:
	if sum(prev) + t > m:
		iskl = []
		minRes = 0
		while sumWithout(prev, iskl) + t > m:
			iskl += [maxWithout(prev, iskl)]
			minRes += 1
		res += [minRes]
	else:
		res += [0]
	prev += [t]
print(' '.join((str(x) for x in res)))


(a, b) = map(int, input().split())
z1 = [0] * 101
z = list(map(int, input().split()))
for i in range(a):
	s = z[i]
	p = 0
	for j in range(1, 101):
		if s + j * z1[j] <= b:
			s += j * z1[j]
		else:
			f = b - s
			p = sum(z1[j:]) + -(f // j)
			break
	z1[z[i]] += 1
	print(p, end=' ')


(n, m) = map(int, input().split())
ticket = list(map(int, input().split()))
sum = 0
for i in range(n):
	sum += ticket[i]
	if sum <= m:
		print(0, end=' ')
	else:
		tmp = sorted(ticket[0:i])
		tmpSum = sum
		c = 0
		index = i - 1
		while True:
			if tmpSum <= m:
				print(c, end=' ')
				break
			else:
				tmpSum -= tmp[index]
				index -= 1
				c += 1


t = input().split(' ')
n = int(t[0])
m = int(t[1])
li = []
re = []
s = input().split(' ')
for i in range(n):
	li.append(int(s[i]))
	re.append(int(s[i]))
f = []
if li[0] > m:
	f.append(1)
else:
	f.append(0)
for i in range(1, n):
	k = []
	k = sorted(re[:i])
	s = li[i]
	c = 0
	g = 0
	for j in range(len(k)):
		if s > m:
			c = len(k) + 1 - j
			g = j
			break
		else:
			g = j
			s += k[j]
	if s > m and c == 0:
		c = len(k) - g
	f.append(c)
for i in range(n):
	print(f[i], end=' ')


def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def si():
	return input()
(n, m) = mi()
a = li()
ans = []
ans.append(0)
for i in range(1, n):
	x = m - a[i]
	b = a[:i]
	b.sort()
	c1 = 0
	for j in range(len(b)):
		x -= b[j]
		c1 += 1
		if x < 0:
			c1 -= 1
			break
	ans.append(i - c1)
print(*ans)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
prev = 0
pref = []
for i in range(n):
	pref.append(prev + l[i])
	prev += l[i]
ans = []
lo = []
for i in range(len(l)):
	if pref[i] <= m:
		ans.append(0)
		lo.append(l[i])
	else:
		z = pref[i]
		z -= l[i]
		count = 0
		lo.sort(reverse=True)
		k = l[i]
		for i in lo:
			if k + z - i > m:
				count += 1
				z -= i
			else:
				count += 1
				break
		ans.append(count)
		lo.append(k)
print(*ans)


(n, m) = map(int, input().split())
l = [int(x) for x in input().split()]
ans = []
for i in range(len(l)):
	a = m - l[i]
	arr = sorted(l[:i])
	a -= sum(arr)
	ct = 0
	while a < 0:
		x = arr[-1]
		arr.pop()
		a += x
		ct += 1
	ans.append(ct)
print(*ans)


nM = list(map(int, input().split()))
Times = list(map(int, input().split()))
Arr = []
for i in range(nM[0]):
	j = 0
	Temp = Times[:i]
	Temp1 = Times[:i + 1]
	while sum(Temp1) > nM[1]:
		j += 1
		ttt = max(Temp)
		Temp.pop(Temp.index(max(Temp)))
		Temp1.pop(Temp1.index(ttt))
	print(j, end=' ')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
(n, M) = map(int, input().split())
l = list(map(int, input().split()))
k = [0] * 100
a = [0] * (n + 1)
ans = []
for i in range(1, n + 1):
	a[i] += a[i - 1] + l[i - 1]
for i in range(1, n + 1):
	if a[i] <= M:
		ans.append(0)
	else:
		d = l[:i - 1]
		asi = 0
		d.sort(reverse=True)
		for j in range(len(d)):
			if a[i] <= M:
				break
			else:
				a[i] -= d[j]
				asi += 1
		ans.append(asi)
print(*ans, sep=' ')


(n, m) = map(int, input().split())
s = list(map(int, input().split()))

def arr_sum(s):
	summ = 0
	for i in range(len(s)):
		summ += s[i]
	return summ
for i in range(n):
	t = s[:i + 1]
	ans = 0
	while arr_sum(t) > m:
		del t[t.index(max(t[:len(t) - 1]))]
		ans += 1
	print(ans, end=' ')


(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
for i in range(n):
	c = m - a[i]
	b = sorted(a[:i], reverse=True)
	s = sum(b)
	j = 0
	while s > c:
		s -= b[j]
		j += 1
	print(j, end=' ')


(n, M) = map(int, input().split())
t = list(map(int, input().split()))
for i in range(n):
	if sum(t[:i + 1]) <= M:
		print(0, end=' ')
	else:
		s = 0
		_t = sorted(t[:i])
		while sum(_t[:i - s]) > M - t[i]:
			s += 1
		print(s, end=' ')


import math
nM = input().split(' ')
n = int(nM[0])
M = int(nM[1])
a = list(map(int, input().split(' ')))
carr = [0 for i in range(100)]
carr[a[0] - 1] += 1
print('0', end=' ')
sum = a[0]
for i in range(1, len(a)):
	failed = 0
	if sum + a[i] > M:
		A = sum + a[i]
		for itr in range(100, 0, -1):
			if A - carr[itr - 1] * itr > M:
				A -= carr[itr - 1] * itr
				failed += carr[itr - 1]
			else:
				failed += math.ceil((A - M) / itr)
				break
		print(failed, end=' ')
	else:
		print(failed, end=' ')
	sum += a[i]
	carr[a[i] - 1] += 1


def Lower_bound(arr, l, r, x, val):
	while l < r:
		mid = (l + r) // 2
		if x + arr[mid] >= val:
			r = mid
		else:
			l = mid + 1
	if x + arr[l] >= val:
		return l - 1
	else:
		return l
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
pre = [0] * n
pre[0] = A[0]
for i in range(1, n):
	pre[i] = pre[i - 1] + A[i]
Ans = [0] * n
for i in range(1, n):
	if m - pre[i] >= 0:
		Ans[i] = 0
	else:
		val = pre[i]
		b = sorted(A[:i])
		c = 0
		for j in range(i - 1, -1, -1):
			if m - val >= 0:
				break
			val -= b[j]
			c += 1
		Ans[i] = c
print(*Ans)


def charu(m):
	global l1
	j = 0
	le = len(l1)
	while l1[j] < m:
		j += 1
		if j == le:
			break
	l1 = l1[:j] + [m] + l1[j:]
(a, b) = list(map(int, input().split()))
l = list(map(int, input().split()))
l1 = [l[0]]
l2 = [0]
su = 0
for i in range(1, a):
	k = 0
	su += l[i - 1]
	su1 = su
	while b - l[i] < su1:
		su1 -= l1[-k - 1]
		k += 1
	l2.append(k)
	charu(l[i])
print(*l2)


arr = list(map(int, input().split()))
(n, m) = (arr[0], arr[1])
s = str(input())
a = [int(i) for i in s.split()]
answers = []
s = 0
count = 0
max_val = 0
k = 0
arr = [0 for i in range(101)]
for elem in a:
	if s + elem > m:
		i = max_val
		s2 = s
		c2 = count
		while s2 + elem > m:
			if s2 - arr[i] * i + elem <= m:
				ans = k - c2 + (arr[i] - (m - elem - (s2 - arr[i] * i)) // i)
				s2 -= i * (arr[i] - (m - elem - (s2 - arr[i] * i)) // i)
			else:
				s2 -= arr[i] * i
				c2 -= arr[i]
				i -= 1
		if elem < max_val:
			arr[elem] += 1
			arr[max_val] -= 1
			s = s - max_val + elem
			j = max_val
			while arr[j] < 1:
				j -= 1
			max_val = j
	else:
		arr[elem] += 1
		s += elem
		ans = k - count
		count += 1
		if elem > max_val:
			max_val = elem
	answers.append(str(ans))
	k += 1
print(' '.join(answers))


(n, m) = map(int, input().split())
arr = [int(z) for z in input().split()]

def binsearch(nums, target):
	left = 0
	right = len(nums) - 1
	while left <= right:
		mid = (left + right) // 2
		if nums[mid] == target:
			return mid
		elif nums[mid] > target:
			right = mid - 1
		elif nums[mid] < target:
			left = mid + 1
	return left
prefsums = [arr[0]]
for i in range(1, n):
	prefsums.append(arr[i] + prefsums[i - 1])
res = []
for i in range(n):
	if prefsums[i] <= m:
		res.append(0)
	else:
		c = prefsums[i] - m
		b = 0
		portion = sorted(arr[:i], reverse=True)
		while c > 0:
			c -= portion[b]
			b += 1
		res.append(b)
print(*res)


m = int(input().split(' ')[1])
ln = [int(i) for i in input().split(' ')]
arr = []
sm = 0
for i in range(0, len(ln)):
	sm += ln[i]
	if sm <= m:
		arr.append(0)
	else:
		fsm = sm
		j = i - 1
		nln = sorted(ln[:j + 1])
		while j > 0:
			fsm -= nln[j]
			if fsm <= m:
				break
			j -= 1
		arr.append(i - j)
print(' '.join([str(i) for i in arr]))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
import bisect
from heapq import *
from math import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def bs(a, l, h, x):
	while l < h:
		mid = (l + h) // 2
		if a[mid] == x:
			return mid
		if a[mid] < x:
			l = mid + 1
		else:
			h = mid
	return l

def sieve(a):
	for i in range(3, 10 ** 6 + 1, 2):
		a[i] = 1
	for i in range(3, 10 ** 6 + 1, 2):
		for j in range(i * i, 10 ** 6 + 1, i):
			a[j] = 0
	a[2] = 1
	return a

def bfs(g, st):
	visited = [0] * len(g)
	visited[st] = 1
	queue = []
	queue.append(st)
	new = []
	while len(queue) != 0:
		s = queue.pop()
		new.append(s)
		for i in g[s]:
			if visited[i] == 0:
				visited[i] = 1
				queue.append(i)
	return new

def solve():
	(n, m) = sep()
	a = lis()
	cnt = [0] * 101
	ans = []
	for i in range(0, n):
		if i == 0:
			ans.append(0)
			cnt[a[i]] += 1
			continue
		rem = m - a[i]
		curr = 0
		count = 0
		for j in range(1, 101):
			if curr + cnt[j] * j <= rem:
				count += cnt[j]
				curr += cnt[j] * j
				continue
			else:
				count += (rem - curr) // j
				break
		ans.append(i - count)
		cnt[a[i]] += 1
	print(*ans)
testcase(1)


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
	if sum(arr[:i + 1]) <= t:
		ans[i] = 0
	else:
		ls = arr[:i]
		ls.sort()
		var = i
		cnt = 0
		while sum(ls[:var]) + arr[i] > t:
			var -= 1
			cnt += 1
		ans[i] = cnt
print(*ans)


ll = lambda : list(map(int, input().split()))
testcases = 1

def find(l, i, m, req):
	l = l[:i]
	l = sorted(l)
	l = reversed(l)
	l = list(l)
	td = sum(l)
	ans = 0
	while m - td < req:
		ans += 1
		td -= l[ans - 1]
	return ans
for testcase in range(testcases):
	[n, m] = ll()
	l = ll()
	ans = [0] * n
	for i in range(1, n):
		ans[i] = find(l, i, m, l[i])
	print(*ans)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
s = 0
for j in range(n):
	s += l[j]
	if s <= m:
		print(0, end=' ')
	else:
		temp = s
		index = j - 1
		count = 0
		x = l[0:j]
		x.sort()
		while temp > m:
			temp -= x[index]
			index -= 1
			count += 1
		print(count, end=' ')


(n, M) = map(int, input().split())
t = list(map(int, input().split()))
prefix_sum = 0
for i in range(n):
	max_ = M - t[i]
	cur_sum = prefix_sum
	prefix_t = sorted(t[:i], reverse=True)
	cnt = 0
	while cur_sum > max_:
		cur_sum -= prefix_t[cnt]
		cnt += 1
	print(cnt, end=' ')
	prefix_sum += t[i]


l = list(map(int, input().split()))
su = 0
final = []
lp = list(map(int, input().split()))
for i in range(l[0]):
	li = []
	su = 0
	n = 0
	for j in range(i + 1):
		su += lp[j]
	if su <= l[1]:
		final.append(n)
	else:
		for j in range(i):
			li.append(lp[j])
		li.sort(reverse=True)
		while su > l[1]:
			su -= li[0]
			li.pop(0)
			n += 1
		final.append(n)
print(*final, sep=' ')


I = lambda : map(int, input().split())
(_, M) = I()
T = list(I())
for (i, t) in enumerate(T):
	x = 0
	while sum(sorted(T[:i])[:i - x]) > M - t:
		x += 1
	print(x, end=' ')


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
print('0', end=' ')
for i in range(1, n):
	student_fail = 0
	new_lst = s[:i + 1]
	while sum(new_lst) > m:
		new_lst.remove(max(new_lst[:-1]))
		student_fail += 1
	print(student_fail, end=' ')


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
v = 0
ans = [0] * 101
for i in range(n):
	cnt = 0
	v += arr[i]
	extra = v - t
	k = 100
	while extra > 0 and k > 0:
		if ans[k] * k >= extra:
			cnt += (extra + k - 1) // k
			break
		elif ans[k] * k < extra:
			extra -= ans[k] * k
			cnt += ans[k]
		k -= 1
	ans[arr[i]] += 1
	print(cnt, end=' ')


from bisect import bisect_left, bisect_right, insort
from collections import Sequence, MutableSequence
from itertools import chain, repeat, starmap
from math import log
from operator import add, eq, ne, gt, ge, lt, le, iadd
from textwrap import dedent
from functools import wraps
from sys import hexversion
if hexversion < 50331648:
	try:
		from _thread import get_ident
	except ImportError:
		from _dummy_thread import get_ident
else:
	from functools import reduce
	try:
		from _thread import get_ident
	except ImportError:
		from _dummy_thread import get_ident

def recursive_repr(fillvalue='...'):

	def decorating_function(user_function):
		repr_running = set()

		@wraps(user_function)
		def wrapper(self):
			key = (id(self), get_ident())
			if key in repr_running:
				return fillvalue
			repr_running.add(key)
			try:
				result = user_function(self)
			finally:
				repr_running.discard(key)
			return result
		return wrapper
	return decorating_function

class SortedList(MutableSequence):
	DEFAULT_LOAD_FACTOR = 1000

	def __init__(self, iterable=None, key=None):
		assert key is None
		self._len = 0
		self._load = self.DEFAULT_LOAD_FACTOR
		self._lists = []
		self._maxes = []
		self._index = []
		self._offset = 0
		if iterable is not None:
			self._update(iterable)

	def __new__(cls, iterable=None, key=None):
		if key is None:
			return object.__new__(cls)
		elif cls is SortedList:
			return object.__new__(SortedKeyList)
		else:
			raise TypeError('inherit SortedKeyList for key argument')

	@property
	def key(self):
		return None

	def _reset(self, load):
		values = reduce(iadd, self._lists, [])
		self._clear()
		self._load = load
		self._update(values)

	def clear(self):
		self._len = 0
		del self._lists[:]
		del self._maxes[:]
		del self._index[:]
		self._offset = 0
	_clear = clear

	def add(self, value):
		_lists = self._lists
		_maxes = self._maxes
		if _maxes:
			pos = bisect_right(_maxes, value)
			if pos == len(_maxes):
				pos -= 1
				_lists[pos].append(value)
				_maxes[pos] = value
			else:
				insort(_lists[pos], value)
			self._expand(pos)
		else:
			_lists.append([value])
			_maxes.append(value)
		self._len += 1

	def _expand(self, pos):
		_load = self._load
		_lists = self._lists
		_index = self._index
		if len(_lists[pos]) > _load << 1:
			_maxes = self._maxes
			_lists_pos = _lists[pos]
			half = _lists_pos[_load:]
			del _lists_pos[_load:]
			_maxes[pos] = _lists_pos[-1]
			_lists.insert(pos + 1, half)
			_maxes.insert(pos + 1, half[-1])
			del _index[:]
		elif _index:
			child = self._offset + pos
			while child:
				_index[child] += 1
				child = child - 1 >> 1
			_index[0] += 1

	def update(self, iterable):
		_lists = self._lists
		_maxes = self._maxes
		values = sorted(iterable)
		if _maxes:
			if len(values) * 4 >= self._len:
				values.extend(chain.from_iterable(_lists))
				values.sort()
				self._clear()
			else:
				_add = self.add
				for val in values:
					_add(val)
				return
		_load = self._load
		_lists.extend((values[pos:pos + _load] for pos in range(0, len(values), _load)))
		_maxes.extend((sublist[-1] for sublist in _lists))
		self._len = len(values)
		del self._index[:]
	_update = update

	def __contains__(self, value):
		_maxes = self._maxes
		if not _maxes:
			return False
		pos = bisect_left(_maxes, value)
		if pos == len(_maxes):
			return False
		_lists = self._lists
		idx = bisect_left(_lists[pos], value)
		return _lists[pos][idx] == value

	def discard(self, value):
		_maxes = self._maxes
		if not _maxes:
			return
		pos = bisect_left(_maxes, value)
		if pos == len(_maxes):
			return
		_lists = self._lists
		idx = bisect_left(_lists[pos], value)
		if _lists[pos][idx] == value:
			self._delete(pos, idx)

	def remove(self, value):
		_maxes = self._maxes
		if not _maxes:
			raise ValueError('{0!r} not in list'.format(value))
		pos = bisect_left(_maxes, value)
		if pos == len(_maxes):
			raise ValueError('{0!r} not in list'.format(value))
		_lists = self._lists
		idx = bisect_left(_lists[pos], value)
		if _lists[pos][idx] == value:
			self._delete(pos, idx)
		else:
			raise ValueError('{0!r} not in list'.format(value))

	def _delete(self, pos, idx):
		_lists = self._lists
		_maxes = self._maxes
		_index = self._index
		_lists_pos = _lists[pos]
		del _lists_pos[idx]
		self._len -= 1
		len_lists_pos = len(_lists_pos)
		if len_lists_pos > self._load >> 1:
			_maxes[pos] = _lists_pos[-1]
			if _index:
				child = self._offset + pos
				while child > 0:
					_index[child] -= 1
					child = child - 1 >> 1
				_index[0] -= 1
		elif len(_lists) > 1:
			if not pos:
				pos += 1
			prev = pos - 1
			_lists[prev].extend(_lists[pos])
			_maxes[prev] = _lists[prev][-1]
			del _lists[pos]
			del _maxes[pos]
			del _index[:]
			self._expand(prev)
		elif len_lists_pos:
			_maxes[pos] = _lists_pos[-1]
		else:
			del _lists[pos]
			del _maxes[pos]
			del _index[:]

	def _loc(self, pos, idx):
		if not pos:
			return idx
		_index = self._index
		if not _index:
			self._build_index()
		total = 0
		pos += self._offset
		while pos:
			if not pos & 1:
				total += _index[pos - 1]
			pos = pos - 1 >> 1
		return total + idx

	def _pos(self, idx):
		if idx < 0:
			last_len = len(self._lists[-1])
			if -idx <= last_len:
				return (len(self._lists) - 1, last_len + idx)
			idx += self._len
			if idx < 0:
				raise IndexError('list index out of range')
		elif idx >= self._len:
			raise IndexError('list index out of range')
		if idx < len(self._lists[0]):
			return (0, idx)
		_index = self._index
		if not _index:
			self._build_index()
		pos = 0
		child = 1
		len_index = len(_index)
		while child < len_index:
			index_child = _index[child]
			if idx < index_child:
				pos = child
			else:
				idx -= index_child
				pos = child + 1
			child = (pos << 1) + 1
		return (pos - self._offset, idx)

	def _build_index(self):
		row0 = list(map(len, self._lists))
		if len(row0) == 1:
			self._index[:] = row0
			self._offset = 0
			return
		head = iter(row0)
		tail = iter(head)
		row1 = list(starmap(add, list(zip(head, tail))))
		if len(row0) & 1:
			row1.append(row0[-1])
		if len(row1) == 1:
			self._index[:] = row1 + row0
			self._offset = 1
			return
		size = 2 ** (int(log(len(row1) - 1, 2)) + 1)
		row1.extend(repeat(0, size - len(row1)))
		tree = [row0, row1]
		while len(tree[-1]) > 1:
			head = iter(tree[-1])
			tail = iter(head)
			row = list(starmap(add, list(zip(head, tail))))
			tree.append(row)
		reduce(iadd, reversed(tree), self._index)
		self._offset = size * 2 - 1

	def __delitem__(self, index):
		if isinstance(index, slice):
			(start, stop, step) = index.indices(self._len)
			if step == 1 and start < stop:
				if start == 0 and stop == self._len:
					return self._clear()
				elif self._len <= 8 * (stop - start):
					values = self._getitem(slice(None, start))
					if stop < self._len:
						values += self._getitem(slice(stop, None))
					self._clear()
					return self._update(values)
			indices = list(range(start, stop, step))
			if step > 0:
				indices = reversed(indices)
			(_pos, _delete) = (self._pos, self._delete)
			for index in indices:
				(pos, idx) = _pos(index)
				_delete(pos, idx)
		else:
			(pos, idx) = self._pos(index)
			self._delete(pos, idx)

	def __getitem__(self, index):
		_lists = self._lists
		if isinstance(index, slice):
			(start, stop, step) = index.indices(self._len)
			if step == 1 and start < stop:
				if start == 0 and stop == self._len:
					return reduce(iadd, self._lists, [])
				(start_pos, start_idx) = self._pos(start)
				if stop == self._len:
					stop_pos = len(_lists) - 1
					stop_idx = len(_lists[stop_pos])
				else:
					(stop_pos, stop_idx) = self._pos(stop)
				if start_pos == stop_pos:
					return _lists[start_pos][start_idx:stop_idx]
				prefix = _lists[start_pos][start_idx:]
				middle = _lists[start_pos + 1:stop_pos]
				result = reduce(iadd, middle, prefix)
				result += _lists[stop_pos][:stop_idx]
				return result
			if step == -1 and start > stop:
				result = self._getitem(slice(stop + 1, start + 1))
				result.reverse()
				return result
			indices = list(range(start, stop, step))
			return list((self._getitem(index) for index in indices))
		else:
			if self._len:
				if index == 0:
					return _lists[0][0]
				elif index == -1:
					return _lists[-1][-1]
			else:
				raise IndexError('list index out of range')
			if 0 <= index < len(_lists[0]):
				return _lists[0][index]
			len_last = len(_lists[-1])
			if -len_last < index < 0:
				return _lists[-1][len_last + index]
			(pos, idx) = self._pos(index)
			return _lists[pos][idx]
	_getitem = __getitem__

	def __setitem__(self, index, value):
		message = 'use ``del sl[index]`` and ``sl.add(value)`` instead'
		raise NotImplementedError(message)

	def __iter__(self):
		return chain.from_iterable(self._lists)

	def __reversed__(self):
		return chain.from_iterable(list(map(reversed, reversed(self._lists))))

	def reverse(self):
		raise NotImplementedError('use ``reversed(sl)`` instead')

	def islice(self, start=None, stop=None, reverse=False):
		_len = self._len
		if not _len:
			return iter(())
		(start, stop, _) = slice(start, stop).indices(self._len)
		if start >= stop:
			return iter(())
		_pos = self._pos
		(min_pos, min_idx) = _pos(start)
		if stop == _len:
			max_pos = len(self._lists) - 1
			max_idx = len(self._lists[-1])
		else:
			(max_pos, max_idx) = _pos(stop)
		return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)

	def _islice(self, min_pos, min_idx, max_pos, max_idx, reverse):
		_lists = self._lists
		if min_pos > max_pos:
			return iter(())
		if min_pos == max_pos:
			if reverse:
				indices = reversed(list(range(min_idx, max_idx)))
				return list(map(_lists[min_pos].__getitem__, indices))
			indices = list(range(min_idx, max_idx))
			return list(map(_lists[min_pos].__getitem__, indices))
		next_pos = min_pos + 1
		if next_pos == max_pos:
			if reverse:
				min_indices = list(range(min_idx, len(_lists[min_pos])))
				max_indices = list(range(max_idx))
				return chain(list(map(_lists[max_pos].__getitem__, reversed(max_indices))), list(map(_lists[min_pos].__getitem__, reversed(min_indices))))
			min_indices = list(range(min_idx, len(_lists[min_pos])))
			max_indices = list(range(max_idx))
			return chain(list(map(_lists[min_pos].__getitem__, min_indices)), list(map(_lists[max_pos].__getitem__, max_indices)))
		if reverse:
			min_indices = list(range(min_idx, len(_lists[min_pos])))
			sublist_indices = list(range(next_pos, max_pos))
			sublists = list(map(_lists.__getitem__, reversed(sublist_indices)))
			max_indices = list(range(max_idx))
			return chain(list(map(_lists[max_pos].__getitem__, reversed(max_indices))), chain.from_iterable(list(map(reversed, sublists))), list(map(_lists[min_pos].__getitem__, reversed(min_indices))))
		min_indices = list(range(min_idx, len(_lists[min_pos])))
		sublist_indices = list(range(next_pos, max_pos))
		sublists = list(map(_lists.__getitem__, sublist_indices))
		max_indices = list(range(max_idx))
		return chain(list(map(_lists[min_pos].__getitem__, min_indices)), chain.from_iterable(sublists), list(map(_lists[max_pos].__getitem__, max_indices)))

	def irange(self, minimum=None, maximum=None, inclusive=(True, True), reverse=False):
		_maxes = self._maxes
		if not _maxes:
			return iter(())
		_lists = self._lists
		if minimum is None:
			min_pos = 0
			min_idx = 0
		elif inclusive[0]:
			min_pos = bisect_left(_maxes, minimum)
			if min_pos == len(_maxes):
				return iter(())
			min_idx = bisect_left(_lists[min_pos], minimum)
		else:
			min_pos = bisect_right(_maxes, minimum)
			if min_pos == len(_maxes):
				return iter(())
			min_idx = bisect_right(_lists[min_pos], minimum)
		if maximum is None:
			max_pos = len(_maxes) - 1
			max_idx = len(_lists[max_pos])
		elif inclusive[1]:
			max_pos = bisect_right(_maxes, maximum)
			if max_pos == len(_maxes):
				max_pos -= 1
				max_idx = len(_lists[max_pos])
			else:
				max_idx = bisect_right(_lists[max_pos], maximum)
		else:
			max_pos = bisect_left(_maxes, maximum)
			if max_pos == len(_maxes):
				max_pos -= 1
				max_idx = len(_lists[max_pos])
			else:
				max_idx = bisect_left(_lists[max_pos], maximum)
		return self._islice(min_pos, min_idx, max_pos, max_idx, reverse)

	def __len__(self):
		return self._len

	def bisect_left(self, value):
		_maxes = self._maxes
		if not _maxes:
			return 0
		pos = bisect_left(_maxes, value)
		if pos == len(_maxes):
			return self._len
		idx = bisect_left(self._lists[pos], value)
		return self._loc(pos, idx)

	def bisect_right(self, value):
		_maxes = self._maxes
		if not _maxes:
			return 0
		pos = bisect_right(_maxes, value)
		if pos == len(_maxes):
			return self._len
		idx = bisect_right(self._lists[pos], value)
		return self._loc(pos, idx)
	bisect = bisect_right
	_bisect_right = bisect_right

	def count(self, value):
		_maxes = self._maxes
		if not _maxes:
			return 0
		pos_left = bisect_left(_maxes, value)
		if pos_left == len(_maxes):
			return 0
		_lists = self._lists
		idx_left = bisect_left(_lists[pos_left], value)
		pos_right = bisect_right(_maxes, value)
		if pos_right == len(_maxes):
			return self._len - self._loc(pos_left, idx_left)
		idx_right = bisect_right(_lists[pos_right], value)
		if pos_left == pos_right:
			return idx_right - idx_left
		right = self._loc(pos_right, idx_right)
		left = self._loc(pos_left, idx_left)
		return right - left

	def copy(self):
		return self.__class__(self)
	__copy__ = copy

	def append(self, value):
		raise NotImplementedError('use ``sl.add(value)`` instead')

	def extend(self, values):
		raise NotImplementedError('use ``sl.update(values)`` instead')

	def insert(self, index, value):
		raise NotImplementedError('use ``sl.add(value)`` instead')

	def pop(self, index=-1):
		if not self._len:
			raise IndexError('pop index out of range')
		_lists = self._lists
		if index == 0:
			val = _lists[0][0]
			self._delete(0, 0)
			return val
		if index == -1:
			pos = len(_lists) - 1
			loc = len(_lists[pos]) - 1
			val = _lists[pos][loc]
			self._delete(pos, loc)
			return val
		if 0 <= index < len(_lists[0]):
			val = _lists[0][index]
			self._delete(0, index)
			return val
		len_last = len(_lists[-1])
		if -len_last < index < 0:
			pos = len(_lists) - 1
			loc = len_last + index
			val = _lists[pos][loc]
			self._delete(pos, loc)
			return val
		(pos, idx) = self._pos(index)
		val = _lists[pos][idx]
		self._delete(pos, idx)
		return val

	def index(self, value, start=None, stop=None):
		_len = self._len
		if not _len:
			raise ValueError('{0!r} is not in list'.format(value))
		if start is None:
			start = 0
		if start < 0:
			start += _len
		if start < 0:
			start = 0
		if stop is None:
			stop = _len
		if stop < 0:
			stop += _len
		if stop > _len:
			stop = _len
		if stop <= start:
			raise ValueError('{0!r} is not in list'.format(value))
		_maxes = self._maxes
		pos_left = bisect_left(_maxes, value)
		if pos_left == len(_maxes):
			raise ValueError('{0!r} is not in list'.format(value))
		_lists = self._lists
		idx_left = bisect_left(_lists[pos_left], value)
		if _lists[pos_left][idx_left] != value:
			raise ValueError('{0!r} is not in list'.format(value))
		stop -= 1
		left = self._loc(pos_left, idx_left)
		if start <= left:
			if left <= stop:
				return left
		else:
			right = self._bisect_right(value) - 1
			if start <= right:
				return start
		raise ValueError('{0!r} is not in list'.format(value))

	def __add__(self, other):
		values = reduce(iadd, self._lists, [])
		values.extend(other)
		return self.__class__(values)
	__radd__ = __add__

	def __iadd__(self, other):
		self._update(other)
		return self

	def __mul__(self, num):
		values = reduce(iadd, self._lists, []) * num
		return self.__class__(values)
	__rmul__ = __mul__

	def __imul__(self, num):
		values = reduce(iadd, self._lists, []) * num
		self._clear()
		self._update(values)
		return self

	def __make_cmp(seq_op, symbol, doc):

		def comparer(self, other):
			if not isinstance(other, Sequence):
				return NotImplemented
			self_len = self._len
			len_other = len(other)
			if self_len != len_other:
				if seq_op is eq:
					return False
				if seq_op is ne:
					return True
			for (alpha, beta) in zip(self, other):
				if alpha != beta:
					return seq_op(alpha, beta)
			return seq_op(self_len, len_other)
		seq_op_name = seq_op.__name__
		comparer.__name__ = '__{0}__'.format(seq_op_name)
		doc_str = 'Return true if and only if sorted list is {0} `other`.\n        ``sl.__{1}__(other)`` <==> ``sl {2} other``\n        Comparisons use lexicographical order as with sequences.\n        Runtime complexity: `O(n)`\n        :param other: `other` sequence\n        :return: true if sorted list is {0} `other`\n        '
		comparer.__doc__ = dedent(doc_str.format(doc, seq_op_name, symbol))
		return comparer
	__eq__ = __make_cmp(eq, '==', 'equal to')
	__ne__ = __make_cmp(ne, '!=', 'not equal to')
	__lt__ = __make_cmp(lt, '<', 'less than')
	__gt__ = __make_cmp(gt, '>', 'greater than')
	__le__ = __make_cmp(le, '<=', 'less than or equal to')
	__ge__ = __make_cmp(ge, '>=', 'greater than or equal to')
	__make_cmp = staticmethod(__make_cmp)

	@recursive_repr()
	def __repr__(self):
		return '{0}({1!r})'.format(type(self).__name__, list(self))

	def _check(self):
		try:
			assert self._load >= 4
			assert len(self._maxes) == len(self._lists)
			assert self._len == sum((len(sublist) for sublist in self._lists))
			for sublist in self._lists:
				for pos in range(1, len(sublist)):
					assert sublist[pos - 1] <= sublist[pos]
			for pos in range(1, len(self._lists)):
				assert self._lists[pos - 1][-1] <= self._lists[pos][0]
			for pos in range(len(self._maxes)):
				assert self._maxes[pos] == self._lists[pos][-1]
			double = self._load << 1
			assert all((len(sublist) <= double for sublist in self._lists))
			half = self._load >> 1
			for pos in range(0, len(self._lists) - 1):
				assert len(self._lists[pos]) >= half
			if self._index:
				assert self._len == self._index[0]
				assert len(self._index) == self._offset + len(self._lists)
				for pos in range(len(self._lists)):
					leaf = self._index[self._offset + pos]
					assert leaf == len(self._lists[pos])
				for pos in range(self._offset):
					child = (pos << 1) + 1
					if child >= len(self._index):
						assert self._index[pos] == 0
					elif child + 1 == len(self._index):
						assert self._index[pos] == self._index[child]
					else:
						child_sum = self._index[child] + self._index[child + 1]
						assert child_sum == self._index[pos]
		except:
			import sys
			import traceback
			traceback.print_exc(file=sys.stdout)
			print('len', self._len)
			print('load', self._load)
			print('offset', self._offset)
			print('len_index', len(self._index))
			print('index', self._index)
			print('len_maxes', len(self._maxes))
			print('maxes', self._maxes)
			print('len_lists', len(self._lists))
			print('lists', self._lists)
			raise

def identity(value):
	return value
(n, m) = list(map(int, input().split()))
a = [int(i) for i in input().split()]
su = 0
t = SortedList()
for i in range(n):
	j = -1
	sucopy = su
	while sucopy + a[i] > m:
		sucopy -= t[j]
		j -= 1
	print(-j - 1, end=' ')
	t.add(a[i])
	su += a[i]


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict
import math
import heapq

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
(n, M) = listIn()
t = listIn()
ans = [0] * n
summ = [t[0]]
for i in range(1, n):
	summ.append(t[i] + summ[i - 1])
for i in range(n):
	if summ[i] <= M:
		ans[i] = 0
	else:
		s = summ[i]
		summ_prev = []
		c = 0
		prev = sorted(t[:i], reverse=True)
		for j in range(len(prev)):
			s -= prev[j]
			c += 1
			if s <= M:
				break
		ans[i] = c
print(*ans)


k = input()
(n, M) = k.split()
n = int(n)
M = int(M)
t = [int(t) for t in input().split()]
c = 0
j = 0
for i in t:
	j += 1
	c += i
	if c <= M:
		print('0', end=' ')
	else:
		t1 = t[:j - 1]
		c1 = 0
		c2 = c
		m = max(t1)
		while c2 > M:
			c1 += 1
			t1.remove(m)
			c2 -= m
			if len(t1) != 0:
				m = max(t1)
		print(c1, end=' ')


[n, M] = [int(i) for i in input().split()]
t = [int(j) for j in input().split()]
sm = 0
ans_arr = []
for x in range(n):
	sm += t[x]
	tmp = []
	for y in range(0, x):
		tmp.append(t[y])
	tmp.sort(reverse=True)
	ans = 0
	tmpsum = 0
	tmpind = 0
	while tmpsum < sm - M:
		tmpsum += tmp[tmpind]
		tmpind += 1
		ans += 1
	ans_arr.append(ans)
for g in range(len(ans_arr)):
	print(ans_arr[g], end=' ')
print()


import math
(n, m) = map(int, input().split())
t = [0] * 101
l = list(map(int, input().split()))
ans = []
cur = 0
for i in range(n):
	cur += l[i]
	if cur <= m:
		print(0, end=' ')
		t[l[i]] += 1
	else:
		sa = cur - m
		count = 0
		for j in range(100, 0, -1):
			if t[j] > 0:
				val = math.ceil(sa / j)
				if val <= t[j]:
					sa -= j * val
					count += val
				else:
					sa -= t[j] * j
					count += t[j]
			if sa <= 0:
				break
		print(count, end=' ')
		t[l[i]] += 1


import heapq
import bisect

def insert(list, n):
	bisect.insort(list, n)
	return list
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
count = a[0]
ans = [0]
li = [a[0]]
heapq.heapify(li)
for i in range(1, n):
	if count + a[i] <= k:
		ans.append(0)
		count += a[i]
		li = insert(li, a[i])
	elif a[i] == k:
		ans.append(i)
		count += a[i]
		li = insert(li, a[i])
	else:
		cnt = 0
		c = 0
		for j in range(len(li) - 1, -1, -1):
			if count - cnt + a[i] <= k:
				break
			else:
				cnt += li[j]
				c += 1
		ans.append(c)
		count += a[i]
		li = insert(li, a[i])
print(*ans)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
sm = 0
ans = []
tm = []
for i in range(len(l)):
	sm += l[i]
	if sm <= m:
		ans.append(0)
		tm.append(l[i])
	else:
		tm.sort(reverse=True)
		k = 0
		ct = 0
		tem = sm
		while tem > m and k < len(tm):
			tem -= tm[k]
			k += 1
			ct += 1
		ans.append(ct)
		tm.append(l[i])
print(' '.join([str(i) for i in ans]))


(a, b) = map(int, input().split())
s = list(map(int, input().split()))
n = 0
c = [0] * 101
for i in range(a):
	n += s[i]
	if n <= b:
		print(0, end=' ')
		c[s[i]] += 1
		continue
	m = n - b
	x = 0
	for j in range(101):
		k = 100 - j
		if c[k] > 0:
			p = m // k
			if p == 0:
				x += 1
				print(x, end=' ')
				break
			elif c[k] > p and m % k != 0:
				x += p + 1
				print(x, end=' ')
				break
			elif c[k] > p and m % k == 0:
				x += p
				print(x, end=' ')
				break
			elif c[k] == p and m % k == 0:
				x += c[k]
				print(x, end=' ')
				break
			else:
				x += c[k]
				m = m - k * c[k]
				if m <= 0:
					print(x - 1, end=' ')
					break
	c[s[i]] += 1


from sys import stdin, stdout, maxsize as mxs
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
from typing import Counter
from itertools import accumulate
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
(n, k) = mp()
arr = lmp()
cnt = l2d(n + 1, 101)
for i in range(1, n + 1):
	for j in range(1, 101):
		if j == arr[i - 1]:
			cnt[i][j] = cnt[i - 1][j] + 1
		else:
			cnt[i][j] = cnt[i - 1][j]
ansl = []
s = 0
for i in range(n):
	s += arr[i]
	c = 0
	if s > k:
		df = s - k
		for j in range(100, 0, -1):
			x = min(cnt[i][j], ceil(df, j))
			df -= j * x
			c += x
			if df <= 0:
				break
	ansl.append(c)
print(*ansl)


(n, M) = map(int, input().split())
a = list(map(int, input().split()))
b = list()
b.append(0)
c = 0
for i in range(1, n):
	d = sorted(a[0:i], reverse=True)
	sn = sum(d)
	kn = 0
	if sn + a[i] <= M:
		c = 0
	else:
		for j in range(len(d)):
			kn += d[j]
			c += 1
			if sn - kn + a[i] <= M:
				break
	b.append(c)
	c = 0
for i in range(len(b)):
	print(b[i], end=' ')


import math

def main():
	(n, m) = map(int, input().split())
	time = list(map(int, input().split()))
	ans = []
	total = 0
	counts = [0] * 100
	for i in range(n):
		if m - total >= time[i]:
			ans.append(0)
		else:
			count = 0
			new = total
			for j in range(99, -1, -1):
				if counts[j] > 0:
					new -= counts[j] * (j + 1)
					if m - new < time[i]:
						count += counts[j]
					else:
						new += counts[j] * (j + 1)
						count += math.ceil((time[i] + new - m) / (j + 1))
						break
			ans.append(count)
		counts[time[i] - 1] += 1
		total += time[i]
	for i in ans:
		print(i, end=' ')
main()


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
for i in range(n):
	s += a[i]
	ss = s
	z = sorted(a[:i], reverse=True)
	j = p = 0
	while ss > m:
		ss -= z[j]
		p += 1
		j += 1
	print(p, end=' ')


import sys

def nline():
	return sys.stdin.readline()[:-1]

def ni():
	return int(sys.stdin.readline())

def na():
	return [int(v) for v in sys.stdin.readline().split()]
(n, m) = na()
arr = na()
sm = 0
count = [0] * 101
for i in range(0, n):
	(diff, k) = (sm + arr[i] - m, 0)
	if diff > 0:
		for j in range(100, -1, -1):
			tmp = count[j] * j
			if tmp >= diff:
				k += (diff + j - 1) // j
				break
			k += count[j]
			diff -= tmp
	print(k, end=' ')
	sm += arr[i]
	count[arr[i]] += 1


(n, M) = [int(x) for x in input().strip().split(' ')]
ti = [int(x) for x in input().strip().split(' ')]
ret = [None] * n
cum = [0] * n
cum[0] = ti[0]
for i in range(1, n):
	cum[i] = ti[i] + cum[i - 1]
for i in range(n):
	if cum[i] <= M:
		ret[i] = str(0)
	else:
		tti = sorted(ti[:i], key=lambda x: -x)
		d = cum[i] - M
		st = 0
		while True:
			d = d - tti[st]
			st += 1
			if d <= 0:
				break
		ret[i] = str(st)
print(' '.join(ret))


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
print(0, end=' ')
for i in range(1, n):
	s = sorted(l[:i])
	total = sum(s) + l[i]
	cnt = 0
	while total > m:
		a = s.pop()
		total -= a
		cnt += 1
	print(cnt, end=' ')
print()


import heapq

def main():
	buf = input()
	buflist = buf.split()
	n = int(buflist[0])
	M = int(buflist[1])
	buf = input()
	buflist = buf.split()
	t = list(map(int, buflist))
	student = []
	minimum = []
	for i in range(n):
		count = 0
		pointer = 0
		while pointer < i:
			if count + student[pointer] <= M - t[i]:
				count += student[pointer]
				pointer += 1
			else:
				break
		minimum.append(i - pointer)
		student.append(t[i])
		student.sort()
	print(' '.join(list(map(str, minimum))))
main()


(n, m) = map(int, input().split())
hihi = list(map(int, input().split()))
(hehe, dem, dem1) = (list(), 0, 0)
for i in range(n):
	hehe = sorted(hihi[0:i])
	for j in range(101):
		dem1 = sum(hehe)
		if hihi[i] + dem1 <= m:
			print(dem, end=' ')
			break
		else:
			hehe = hehe[0:len(hehe) - 1]
			dem += 1
	(hehe, dem1, dem) = (list(), 0, 0)


(n, M) = [int(_) for _ in input().split()]
t = [int(_) for _ in input().split()]
q = []
for x in t:
	mi = M - x
	s = sum(q)
	i = 0
	while mi < s:
		i -= 1
		s -= q[i]
	print(abs(i), end=' ')
	q.append(x)
	for i in range(-1, -len(q), -1):
		if q[i] < q[i - 1]:
			(q[i], q[i - 1]) = (q[i - 1], q[i])


(n, m) = [int(i) for i in input().split()]
line = [int(x) for x in input().split()]
count = {i + 1: 0 for i in range(100)}
sum = 0
for i in line:
	p = sum + i
	t = 0
	if p > m:
		for j in range(100, 0, -1):
			if count[j] == 0:
				continue
			elif p - count[j] * j > m:
				p -= count[j] * j
				t += count[j]
			else:
				l = (p - m) // j
				if p - l * j > m:
					l += 1
				t += l
				break
	count[i] += 1
	sum += i
	print(t, end=' ')


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
r = '0'
for i in range(1, n):
	a = sorted(s[:i], reverse=True)
	b = sum(a) + s[i]
	d = 0
	while 1:
		if b <= m:
			break
		else:
			b -= a[d]
			d += 1
	r += ' ' + str(d)
print(r)


from __future__ import division, print_function
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
from math import ceil, floor, log, sqrt, factorial, pow, pi

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p1
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph():
	d = {}
	(v, e) = mi()
	for i in range(e):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d.keys():
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(l, n):
	d = {}
	for i in range(1, n + 1):
		if i not in d.keys():
			d[i] = l[i]
		else:
			d[i].append(l[i])
	return d
(n, m) = mi()
l = li()
s = 0
b = []
for i in range(n):
	s += l[i]
	if s <= m:
		b.append(0)
	else:
		z = sorted(l[:i])[::-1]
		x = s
		for j in range(i):
			x -= z[j]
			if x <= m:
				b.append(j + 1)
				break
print(' '.join(map(str, b)))


(n, T) = list(map(lambda x: int(x), input().split(' ')))
students = list(map(lambda x: int(x), input().split(' ')))
out = []
for i in range(0, len(students)):
	ans = 0
	scope = students[0:i + 1]
	excess = sum(scope) - T
	sortedScope = sorted(scope[:-1], reverse=True)
	while excess > 0:
		excess -= sortedScope.pop(0)
		ans += 1
	out.append(ans)
for i in out:
	print(i)


import sys
read = lambda : sys.stdin.readline().strip()
write = lambda x: sys.stdout.write(x)
(n, m) = map(int, input().split())
t = list(map(int, input().split()))
ans = [0]
for k in range(1, n):
	a = sorted(t[:k])
	s = [t[k], -1]
	for (j, i) in enumerate(a):
		if s[0] + i > m:
			s[1] = j
			break
		else:
			s[0] += i
	if s[1] == -1:
		ans.append(0)
	else:
		ans.append(k - s[1])
print(*ans)


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
from bisect import bisect_left, insort_left
l = []
cnt = 0
r = [0] * n
for (i, x) in enumerate(a):
	if cnt + x <= m:
		insort_left(l, x)
		r[i] = 0
		cnt += x
	else:
		tmp = 0
		for j in range(len(l) - 1, -1, -1):
			tmp += l[j]
			if cnt + x <= m + tmp:
				break
		r[i] = len(l) - j
		insort_left(l, x)
		cnt += x
print(*r)


class BinHeap:

	def __init__(self):
		self.heap = []

	def get_max(self):
		if len(self.heap) > 0:
			return self.heap[0]

	def add_elem(self, elem):
		self.heap.append(elem)
		index = len(self.heap) - 1
		while index > 0 and self.heap[index] > self.heap[(index - 1) // 2]:
			(self.heap[index], self.heap[(index - 1) // 2]) = (self.heap[(index - 1) // 2], self.heap[index])
			index = (index - 1) // 2

	def delete_min(self):
		if len(self.heap) == 0:
			pass
		else:
			elem = self.heap[0]
			(self.heap[0], self.heap[len(self.heap) - 1]) = (self.heap[len(self.heap) - 1], self.heap[0])
			self.heap.pop()
			self.heapfy(0)
			return elem

	def heapfy(self, index):
		left = index * 2 + 1
		right = index * 2 + 2
		size_heap = len(self.heap)
		if size_heap > left and self.heap[left] > self.heap[index]:
			elem = left
		else:
			elem = index
		if size_heap > right and self.heap[right] > self.heap[elem]:
			elem = right
		if elem != index:
			(self.heap[elem], self.heap[index]) = (self.heap[index], self.heap[elem])
			self.heapfy(elem)
arr = list(map(int, input().split()))
(n, m) = (arr[0], arr[1])
arr = list(map(int, input().split()))
heap = BinHeap()
heap.heap
answers = []
s = 0
for i in range(n):
	ans = i - len(heap.heap)
	times = []
	if s + arr[i] > m:
		while s + arr[i] > m:
			times.append(heap.delete_min())
			ans += 1
			s -= times[-1]
		for elem in times:
			heap.add_elem(elem)
			s += elem
		if heap.get_max() > arr[i]:
			s -= heap.delete_min()
			heap.add_elem(arr[i])
			s += arr[i]
	else:
		s += arr[i]
		heap.add_elem(arr[i])
	answers.append(ans)
ans = ''
for elem in answers:
	ans += str(elem) + ' '
print(ans[:-1])


from sys import *
buckets = [0] * 101
(n, M) = map(int, stdin.readline().split())
ts = [int(t) for t in stdin.readline().split()]
full_sum = 0
for i in range(n):
	cur_M = M
	cur_sum = full_sum
	bucket_idx = 100
	ans = 0
	while cur_sum > cur_M - ts[i]:
		if cur_sum - cur_M + ts[i] >= buckets[bucket_idx] * bucket_idx:
			cur_sum -= buckets[bucket_idx] * bucket_idx
			ans += buckets[bucket_idx]
		else:
			tmp = (cur_sum - cur_M + ts[i] - 1) // bucket_idx + 1
			ans += tmp
			cur_sum -= bucket_idx * tmp
		bucket_idx -= 1
	stdout.write(str(ans) + ' ')
	full_sum += ts[i]
	buckets[ts[i]] += 1
stdout.write('\n')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
k = []
for i in range(1, n):
	b = a[:i]
	b.sort()
	b = b[::-1]
	k.append(b)
ans = [0]
sm = a[0]
for i in range(1, n):
	sm += a[i]
	cnt = 0
	x = 0
	if sm > m:
		y = sm
		for j in range(i):
			x = k[i - 1][j]
			y -= x
			cnt += 1
			if y <= m:
				break
	ans.append(cnt)
for i in range(n):
	print(ans[i], end=' ')


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
l1 = [0] * 110
for i in l:
	ans = 0
	res = 0
	for j in range(1, 101, 1):
		mi = min((b - i - res) // j, l1[j])
		ans += mi
		res += mi * j
	l1[i] += 1
	print(sum(l1) - ans - 1, end=' ')
print()


(n, M) = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
for (i, j) in enumerate(arr):
	passed = arr[:i]
	elapsed = sum(passed)
	if elapsed + j > M:
		cnt = 0
		time = elapsed + j
		while time > M:
			cnt += 1
			time -= max(passed)
			passed.pop(passed.index(max(passed)))
		print(cnt, end=' ')
	else:
		print(0, end=' ')


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
c = []
n = 0
for i in range(a):
	n += l[i]
	if n <= b:
		c.append(0)
		continue
	m = n
	l[:i] = sorted(l[:i], reverse=True)
	x = 0
	for j in range(i):
		m = m - l[j]
		x += 1
		if m <= b:
			c.append(x)
			break
for k in range(a):
	print(c[k], end=' ')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
b = []
for i in range(n):
	b.sort()
	temp = 0
	k = 0
	s += a[i]
	if s > m:
		for j in range(len(b) - 1, -1, -1):
			temp += b[j]
			k += 1
			if temp >= s - m:
				break
	print(k, end=' ')
	b.append(a[i])


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
r = '0 '
for i in range(1, a):
	d = []
	for j in range(i):
		d.append(c[j])
	u = 0
	while b - sum(d) - c[i] < 0:
		m = max(d)
		j = 0
		while j < len(d):
			if d[j] == m:
				d.pop(j)
				break
			j += 1
		u += 1
	r += str(u) + ' '
print(r)


import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(100000)
input = sys.stdin.readline

def read_int():
	return int(input())

def read_int_n():
	return list(map(int, input().split()))

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

def read_str():
	return input().strip()

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

def slv(N, M, S):
	ans = []
	for i in range(N):
		m = sum(S[:i + 1])
		if m <= M:
			ans.append(0)
		else:
			s = S[:i]
			s.sort()
			c = 0
			while m > M:
				m -= s.pop()
				c += 1
			ans.append(c)
	return ' '.join(map(str, ans))

def main():
	(N, M) = read_int_n()
	S = read_int_n()
	print(slv(N, M, S))
main()


(n, m) = map(int, input().split())
z = list(map(int, input().split()))
ans = []
csum = 0
for i in range(len(z)):
	csum += z[i]
	if csum <= m:
		ans.append(0)
	else:
		tmparr = z[0:i]
		tcsum = csum
		tmparr.sort(reverse=True)
		for i in range(len(tmparr)):
			tcsum -= tmparr[i]
			if tcsum <= m:
				ans.append(i + 1)
				break
print(*ans)


(n, m) = map(int, input().split())
ti = list(map(int, input().split()))
for i in range(n):
	t = list(ti[:i])
	while True:
		if sum(t) + ti[i] <= m:
			break
		del t[t.index(max(t))]
	print(i - len(t), end=' ')
print()


(n, m) = map(int, input().split())
l = [int(i) for i in input().split()]
pre = [0] * (n + 1)
for i in range(1, n + 1):
	pre[i] = pre[i - 1] + l[i - 1]
ans = [0] * n
arr = []
for i in range(n):
	if pre[i + 1] <= m:
		ans[i] = 0
		arr.append(l[i])
	else:
		arr.sort()
		rem = m - l[i]
		c = 0
		sm = pre[i]
		j = len(arr) - 1
		while sm > rem:
			sm -= arr[j]
			j -= 1
			c += 1
		ans[i] = c
		arr.append(l[i])
print(*ans)


(n, m) = map(int, input().split())
t = list(map(int, input().split()))
su = []
ans = []
for i in range(n):
	su.append(sum(t[:i + 1]))
for i in range(n):
	if su[i] <= m:
		ans.append(0)
	else:
		cnt = 0
		k = []
		for z in range(i):
			k.append(t[z])
		k.sort(reverse=True)
		j = 0
		while su[i] > m:
			su[i] -= k[j]
			cnt += 1
			j += 1
		ans.append(cnt)
for i in ans:
	print(i, end=' ')


(n, m) = [int(x) for x in input().split()]
times = [int(x) for x in input().split()]
import heapq

def calculate_times(times, m):
	prefix_sum = 0
	q = []
	res = []
	for t in times:
		prefix_sum += t
		if prefix_sum <= m:
			res.append(0)
		else:
			count = 0
			poped = []
			diff = prefix_sum - m
			while diff > 0:
				count += 1
				val = heapq.heappop(q)
				diff += val
				poped.append(val)
			for val in poped:
				heapq.heappush(q, val)
			res.append(count)
		heapq.heappush(q, -t)
	return res
print(' '.join([str(x) for x in calculate_times(times, m)]))


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = []
c = []
s = 0
for i in a:
	cnt = 0
	v = 0
	s = s + i
	if s > k:
		while s > k:
			b.sort()
			l = len(b) - 1 - cnt
			s -= b[l]
			v += b[l]
			cnt += 1
		c.append(cnt)
		b.append(i)
		s += v
	else:
		b.append(i)
		c.append(0)
for i in c:
	print(i, end=' ')


(n, s) = map(int, input().split())
a = list(map(int, input().split()))
count = 0
b = []
for i in range(n):
	b = []
	for j in range(i):
		b.append(a[j])
	b.sort()
	count = sum(b) + a[i]
	c = 0
	while count > s:
		count -= b[-1]
		b.pop(-1)
		c += 1
	print(c, end=' ')
print()


import bisect
(a, b) = map(int, input().split())
A = list(map(int, input().split()))
B = []
IN = []
kk = 0
for i in range(len(A)):
	kkl = int(kk) + A[i]
	j = 0
	while kkl > b and j < len(B):
		kkl -= B[-j - 1]
		j += 1
	IN.append(j)
	bisect.insort(B, A[i])
	kk += A[i]
print(*IN)


(n, m) = map(int, input().split())
t = list(map(int, input().split()))
t2 = []
cur = 0
res = []
for i in t:
	if sum(t2) + i <= m:
		t2.append(i)
		res.append(0)
	else:
		j = 0
		t3 = t2[:]
		while sum(t3) + i > m:
			t3.remove(max(t3))
			j += 1
		t2.append(i)
		res.append(j)
for i in res:
	print(i, end=' ')


import math
import os
import random
import re
import sys
(n, m) = map(int, input().split())
ans = 0
a = list(map(int, input().split()))
for i in range(n):
	temp = sorted(a[:i])
	sum = a[i]
	j = 0
	while j < len(temp):
		sum = sum + temp[j]
		if sum <= m:
			j = j + 1
		else:
			break
	ans = len(temp) - j
	print(ans, end=' ')


import itertools
from heapq import heapify, heappush, heappop
import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
t = list(map(int, input().split()))
tsum = list(itertools.accumulate(t))
ans = []
for i in range(n):
	if tsum[i] <= m:
		ans.append(0)
	else:
		heap = [-k for k in t[:i]]
		heapify(heap)
		remain = sum(t[:i]) - m
		count = 0
		for j in range(i, n):
			uselist = []
			remain += t[j]
			while remain > 0:
				count += 1
				use = heappop(heap)
				remain += use
				uselist.append(use)
			else:
				ans.append(count)
				uselist.sort(reverse=True)
			summ = 0
			for uses in uselist[:100]:
				heappush(heap, uses)
				remain -= uses
				summ -= uses
				count -= 1
				if summ > 100:
					break
			heappush(heap, -t[j])
		break
print(' '.join(map(str, ans)))


(n, m) = map(int, input().split())
t = list(map(int, input().split()))
mm = []
ss = 0
for i in range(n):
	if sum(mm) + t[i] <= m:
		print(0, end=' ')
	else:
		mm = sorted(mm)
		ss = sum(mm)
		xx = 0
		tmp = []
		while ss + t[i] > m:
			tmp.append(mm.pop())
			ss -= tmp[-1]
			xx += 1
		print(xx, end=' ')
		while len(tmp) != 0:
			mm.append(tmp.pop())
	mm.append(t[i])


R = lambda : map(int, input().split())
(n, m) = R()
cnts = [0] * 105
tcnt = 0
for x in R():
	cnt = acc = 0
	for (i, c) in enumerate(cnts):
		if acc + i * c + x <= m:
			(cnt, acc) = (cnt + c, acc + i * c)
		else:
			cnt += (m - acc - x) // i
			break
	print(tcnt - cnt, end=' ')
	cnts[x] += 1
	tcnt += 1


from bisect import insort
(n, m) = [int(x) for x in input().split()]
students = [int(x) for x in input().split()]
s = 0
heap = []
std = []
for i in students:
	if s + i > m:
		std = heap.copy()
		t = 0
		q = s
		while q + i > m:
			q -= std.pop()
			t += 1
		print(t, end=' ')
	else:
		print('0 ', end='')
	s += i
	insort(heap, i)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
c = 0
C = []
ans = []
for i in range(n):
	c += a[i]
	if i != 0:
		C.append(a[i - 1])
		C.sort()
	b = c
	d = 0
	m = 1
	while b > k:
		d += 1
		s = C[len(C) - m]
		m += 1
		b -= s
	ans.append(d)
for i in ans:
	print(i, end=' ')


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))

def meth(arr):
	val = arr[-1]
	arr = arr[0:-1]
	arr.sort()
	count = 0
	fl = 0
	br = 0
	for i in range(len(arr)):
		if val > m:
			if fl == 1:
				count -= 1
			br = 12
			break
		else:
			fl = 1
			val += arr[i]
			count += 1
	if br == 0 and val > m:
		if fl == 1:
			count -= 1
	print(len(arr) - count, end=' ')
for i in range(n):
	meth(a[0:i + 1])
print()


(n, m) = map(int, input().split())
lst = [int(i) for i in input().split()]
pases = [0]
kk = lst[0]
for i in range(1, len(lst)):
	kk += lst[i]
	if kk <= m:
		pases.append(0)
	else:
		k1 = sorted(lst[:i])
		temp_sum = kk
		ii = len(k1) - 1
		cnt = 0
		while temp_sum > m:
			temp_sum -= k1[ii]
			cnt += 1
			ii -= 1
		pases.append(cnt)
print(*pases)


(n, M) = map(int, input().split())
timeList = list(map(int, input().split()))
answerList = []
for i in range(n):
	currentList = timeList[:i + 1]
	s = sum(currentList)
	answer = 0
	if s <= M:
		answerList.append(0)
		continue
	else:
		while s > M:
			m = max(currentList[:len(currentList) - 1])
			currentList.remove(m)
			s = sum(currentList)
			answer += 1
	answerList.append(answer)
print(' '.join(map(str, answerList)))


(n, m) = map(int, input().split())
t = list(map(int, input().split()))
tIndex = {}
tIndexSum = {}
s = 0
for i in range(n):
	r = 0
	if s + t[i] > m:
		keys = list(tIndex.keys())
		keys.sort(reverse=True)
		s1 = s
		for k in keys:
			if s1 - tIndex[k] * k + t[i] > m:
				s1 -= tIndex[k] * k
				r += tIndex[k]
			else:
				r += (s1 + t[i] - m) // k
				s1 -= (s1 + t[i] - m) // k * k
				if s1 + t[i] > m:
					s1 -= k
					r += 1
			if s1 + t[i] <= m:
				break
	print(r, end=' ')
	if not t[i] in tIndex:
		tIndex[t[i]] = 0
	tIndex[t[i]] += 1
	if not t[i] in tIndexSum:
		tIndexSum[t[i]] = 0
	tIndexSum[t[i]] += t[i]
	s += t[i]


(n, m) = map(int, input().split())
t = list(map(int, input().split()))
curr = 0
arr = []
ans = []
for i in range(n):
	curr += t[i]
	if curr <= m:
		ans.append(0)
	else:
		temp = sorted(arr, reverse=True)
		cc = 0
		rt = 0
		for j in range(len(temp)):
			cc += temp[j]
			rt += 1
			if curr - cc <= m:
				break
		ans.append(rt)
	arr.append(t[i])
for i in ans:
	print(i, end=' ')
print()


(n, M) = map(int, input().split(' '))
y = list(map(int, input().split()))
c = []
c.append(y[0])
y[0] = 0
j = 1
while j < n:
	s = sum(c)
	if s + y[j] < M:
		c.append(y[j])
		y[j] = 0
	else:
		c = sorted(c)
		s = s + y[j]
		count = 1
		while s > M:
			s = s - c[-count]
			count += 1
		c.append(y[j])
		y[j] = count - 1
	j = j + 1
print(*y)


from sys import stdin, stdout
from itertools import accumulate
import math
(n, M) = stdin.readline().strip().split(' ')
(n, M) = (int(n), int(M))
ti = list(map(int, stdin.readline().strip().split(' ')))
ps_ti = list(accumulate(ti))
tarr = [0 for i in range(101)]
ansarr = []
for j in range(len(ti)):
	if ps_ti[j] <= M:
		ansarr.append('0')
		tarr[ti[j]] += 1
	else:
		rm = 0
		diff = ps_ti[j] - M
		for i in range(100, 0, -1):
			if tarr[i] == 0:
				continue
			elif diff <= i * tarr[i]:
				rm += math.ceil(diff / i)
				break
			else:
				diff -= i * tarr[i]
				rm += tarr[i]
		ansarr.append(str(rm))
		tarr[ti[j]] += 1
stdout.write(' '.join(ansarr))


import heapq
(n, m) = map(int, input().split())
t = [int(x) for x in input().split()]
a = []
heapq.heapify(a)
s = 0
r = []
for tt in t:
	gg = []
	i = 0
	while s > m - tt:
		i += 1
		ss = -heapq.heappop(a)
		s -= ss
		gg.append(-ss)
	heapq.heappush(a, -tt)
	s += tt
	for g in gg:
		heapq.heappush(a, g)
		s += -g
	r.append(i)
print(*r)


(n, m) = map(int, input().split())
lst = list(map(int, input().split()))
ans = [0] * n
stk = []
summ = 0
cur = 0
for i in range(n):
	if summ + lst[i] > m:
		arr = lst[:i].copy()
		arr.sort()
		temp = summ
		j = i - 1
		while j >= 0 and temp + lst[i] > m:
			temp -= arr[j]
			j -= 1
		ans[i] = i - j - 1
	else:
		ans[i] = 0
	summ += lst[i]
print(*ans)


(n, M) = map(int, input().split())
x = list(map(int, input().split()))
cnt = 0
for i in range(n):
	if sum(x[:i + 1]) <= M:
		print(0, end=' ')
	else:
		cur_sum = sum(x[:i + 1])
		for j in range(i, 0, -1):
			b = x[:i]
			b.sort()
			if cur_sum - b[j - 1] > M:
				cur_sum -= b[j - 1]
				cnt += 1
			else:
				cnt += 1
				print(cnt, end=' ')
				cnt = 0
				break


(n, mins) = [int(x) for x in input().split()]
inp = [int(x) for x in input().split()]
lis = list()
total = inp[0]
arr = list()
arr.append(0)
lis.append(inp[0])
for x in range(1, n):
	counter = 0
	total += inp[x]
	tempTotal = total
	if total > mins:
		lis.sort()
	while tempTotal > mins:
		tempTotal -= lis[len(lis) - counter - 1]
		counter += 1
	arr.append(counter)
	lis.append(inp[x])
for i in arr:
	print(i, end=' ')


from heapq import heappush, heappop
(N, M) = map(int, input().split())
List = [int(x) for x in input().split()]
Ans = []
Heap = []
Time = 0
for i in range(N):
	Time += List[i]
	if Time <= M:
		Ans.append(0)
		heappush(Heap, -List[i])
	else:
		Copy = Heap.copy()
		Chahiye = Time - M
		X = 0
		for j in range(len(Ans)):
			X += -heappop(Copy)
			if X >= Chahiye:
				Ans.append(j + 1)
				break
		heappush(Heap, -List[i])
print(*Ans)


(n, m) = map(int, input().split())
t = list(map(int, input().split()))
cur = 0
c = 0
l = []
for i in t:
	if cur + i <= m:
		print('0', end=' ')
		cur += i
		c += 1
		l.append(i)
	else:
		cur += i
		ans = cur
		coun = 0
		l_2 = sorted(l, reverse=True)
		while ans > m:
			ans -= l_2[coun]
			coun += 1
		l.append(i)
		print(coun, end=' ')


from math import *
(n, m) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
for i in range(n):
	s = a[:i]
	s = sorted(s)
	s = s[::-1]
	now = sum(s)
	c = 0
	j = 0
	while j < len(s) and now + a[i] > m:
		now -= s[j]
		j += 1
		c += 1
	print(c, end=' ')
print()


import sys, itertools
(n, m) = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
pf = [0] * n
pf[0] = arr[0]
for i in range(1, n):
	pf[i] = pf[i - 1] + arr[i]
ans = [0] * n
for i in range(1, n):
	if pf[i] <= m:
		continue
	else:
		temp = []
		for j in range(i):
			temp.append(arr[j])
		temp.sort()
		cnt = 0
		while temp:
			if sum(temp) + arr[i] <= m:
				break
			temp.pop()
			cnt += 1
		ans[i] = cnt
print(' '.join(map(str, ans)))


def add(n):
	global a
	a.append(n)
	a.sort()
(n, m) = map(int, input().split())
s = list(map(int, input().split()))
ssum = s[0]
a = list()
ans = [0] * n
add(s[0])
for i in range(1, n):
	if ssum + s[i] > m:
		j = len(a) - 1
		temp = ssum
		while temp + s[i] > m:
			ans[i] += 1
			temp -= a[j]
			j -= 1
	ssum += s[i]
	add(s[i])
print(*ans)


import heapq
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
sm = 0
qw = []
for i in range(n):
	if sm + a[i] > m:
		q = []
		ans = 0
		while sm + a[i] > m:
			if len(qw) == 0:
				print('qwqwqwqw')
			e = heapq.heappop(qw)
			sm -= -e
			q.append(e)
			ans += 1
		print(ans, end=' ')
		for x in q:
			heapq.heappush(qw, x)
			sm += -x
		sm += a[i]
		heapq.heappush(qw, -a[i])
	else:
		heapq.heappush(qw, -a[i])
		sm += a[i]
		print(0, end=' ')


class Student:

	def __init__(self, time):
		self.time = time
		self.wait = 0

	def __repr__(self):
		return '{0}'.format(self.wait)

	def __eq__(self, other):
		if self.time == other.time:
			return True
		else:
			return False

	def __lt__(self, other):
		if self.time < other.time:
			return True
		else:
			return False

	def __gt__(self, other):
		if self.time > other.time:
			return True
		else:
			return False
flag = False
studentArray = []
x = input()
n = int(x[0])
if x[1] != ' ':
	n1 = int(x[1])
	n = n * 10 + n1
if x[2] == '0':
	n2 = int(x[2])
	n = n * 10 + n2
m = int(x[-1])
if x[-1] == '0' and x[-2] == '0' and (x[-3] == '1'):
	m = 100
elif x[-2] != ' ':
	m1 = int(x[-2])
	m = m1 * 10 + m
y = input()
c = 0
for i in range(0, n):
	flag = False
	t = int(y[c])
	if c < len(y) - 2:
		if y[c + 1] != ' ' and y[c + 2] != ' ':
			flag = True
			t = 100
			c += 4
	if c < len(y) - 1 and (not flag):
		if y[c + 1] != ' ':
			t1 = int(y[c + 1])
			t = t * 10 + t1
			c += 3
		else:
			c += 2
	studentArray.append(Student(t))
sum = 0
for i in range(0, n):
	sum += studentArray[i].time
	tempsum = sum
	if sum > m:
		counter = 0
		temp = studentArray[:i]
		temp.sort()
		for j in range(i - 1, -1, -1):
			counter += 1
			tempsum = tempsum - temp[j].time
			if tempsum <= m:
				break
		studentArray[i].wait = counter
for student in studentArray:
	print(student, end=' ')


(n, t) = list(map(int, input().split()))
l = list(map(int, input().split()))
ans = []
for i in range(1, n + 1):
	s = sum(l[:i])
	count = 0
	if s <= t:
		ans.append(0)
		continue
	else:
		l2 = [x for x in l[:i - 1]]
		while s > t:
			s -= max(l2)
			l2.remove(max(l2))
			count += 1
		ans.append(count)
print(' '.join(map(str, ans)))


(a, b) = list(map(int, input().split()))
kam = list(map(int, input().split()))
lam = []
ans = []
count = 0
for it in kam:
	if count + it <= b:
		ans.append(0)
		count += it
	else:
		jim = count
		kj = 0
		for iit in lam:
			kj += 1
			jim -= iit
			if jim + it <= b:
				ans.append(kj)
				break
			else:
				pass
		count += it
	lam.append(it)
	lam.sort(reverse=True)
print(*ans)


(n, m) = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
li = []
j = 0
while j < n:
	t = l[len(l) - 1]
	l.pop()
	a = list(l)
	a.sort()
	s = 0
	c = 0
	for i in range(0, len(a)):
		s += a[i]
		if s <= m - t:
			c += 1
		else:
			break
	li.append(len(a) - c)
	j += 1
li.reverse()
print(*li, sep=' ')


(n, m) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
res = [0]
suma = a[0]
for i in range(1, n):
	suma += a[i]
	if suma > m:
		cut = a[:i]
		cut = sorted(cut, reverse=True)
		sumb = a[i] + sum(cut)
		for j in range(len(cut)):
			sumb -= cut[j]
			if sumb <= m:
				res.append(j + 1)
				break
	else:
		res.append(0)
print(*res)


[n, M] = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
s = 0
res = []
for i in range(n):
	ti = t[i]
	r = M - ti
	si = s
	if si <= r:
		res.append(0)
	else:
		j = i - 1
		x = 0
		while si > r:
			si -= t[j]
			j -= 1
			x += 1
		res.append(x)
	j = i
	s += t[i]
	while j > 0 and t[j] < t[j - 1]:
		(t[j], t[j - 1]) = (t[j - 1], t[j])
		j -= 1
print(' '.join([str(i) for i in res]))


import bisect
(n, m) = map(int, input().split())
t = list(map(int, input().split()))
max_numbers = []
total_sum = 0
ans = []
for s in t:
	total_sum += s
	if total_sum <= m:
		ans.append(0)
	else:
		total_sub = 0
		num = 0
		for e in max_numbers[::-1]:
			total_sub += e
			num += 1
			if total_sum - total_sub <= m:
				ans.append(num)
				break
	bisect.insort(max_numbers, s)
print(*ans)


def maxSelections(z, A, n, k):
	A.sort()
	sum = z
	count = 0
	for i in range(n - 1):
		sum = sum + A[i]
		if sum > k:
			break
		count += 1
	return count
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
l = []
for i in range(n):
	mn = maxSelections(a[i], a[:i], i + 1, m)
	if i - mn <= 0:
		l.append(0)
	else:
		l.append(i - mn)
print(*l, end=' ')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		(n, m) = LI()
		a = LI()
		r = []
		t = 0
		q1 = []
		q2 = []
		for (i, c) in enumerate(a):
			if q1 and q2:
				t1 = -heapq.heappop(q1)
				t -= t1
				while q2:
					t2 = heapq.heappop(q2)
					if t2 < t1 and t + t2 + c <= m:
						t += t2
						heapq.heappush(q1, -t2)
					else:
						heapq.heappush(q2, t2)
						break
				if t + t1 + c <= m:
					t += t1
					heapq.heappush(q1, -t1)
				else:
					heapq.heappush(q2, t1)
			while t + c > m:
				t1 = -heapq.heappop(q1)
				t -= t1
				heapq.heappush(q2, t1)
			t += c
			heapq.heappush(q1, -c)
			r.append(i + 1 - len(q1))
		rr.append(JA(r, ' '))
	return JA(rr, '\n')
print(main())


(x, y) = map(int, input().split())
s = list(map(int, input().split()))
tm = []
res = []
sm = 0
for n in range(x):
	sm += s[n]
	if sm > y:
		d = sm - y
		p = 0
		while d > 0:
			d -= tm[p]
			p += 1
		res.append(p)
	else:
		res.append(0)
	tm.append(s[n])
	tm.sort()
	tm.reverse()
print(*res)


(a, b) = map(int, input().split())
s = list(map(int, input().split()))
n = 0
li = []
l = a - 1
for i in range(l):
	li.append([s[i], i])
li[:l] = sorted(li[:l], reverse=True)
u = len(li)
for i in range(a):
	n += s[i]
	if n <= b:
		print(0, end=' ')
		continue
	m = n
	x = 0
	for j in range(l):
		if li[j][1] < i:
			m = m - li[j][0]
			x += 1
			if m <= b:
				print(x, end=' ')
				break


import heapq

def main():
	(n, m) = map(int, input().split())
	heap = []
	time = list(map(int, input().split()))
	ans = []
	total = 0
	for i in range(n):
		if m - total >= time[i]:
			ans.append(0)
		else:
			new = []
			while True:
				curr = heapq.heappop(heap)
				new.append(curr)
				total -= abs(curr)
				if m - total >= time[i]:
					ans.append(len(new))
					break
			for j in new:
				heapq.heappush(heap, j)
				total += abs(j)
		heapq.heappush(heap, -time[i])
		total += time[i]
	for i in ans:
		print(i, end=' ')
main()


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = []
for i in range(n):
	b = sorted(a[:i])
	su = a[i]
	count = 0
	for i in range(len(b)):
		su += b[i]
		if su > m:
			count += 1
			su -= b[i]
	ans.append(count)
print(*ans)


(n, m) = map(int, input().split())
students = list(map(int, input().split()))
for i in range(n):
	list1 = students[:i + 1]
	list1.sort()
	sum1 = 0
	j = 0
	lim = m - students[i]
	while sum1 <= lim and j < len(list1):
		sum1 += list1[j]
		j += 1
	if sum1 > m:
		j -= 1
	print(len(list1) - j)


def solve(n, time, seq):
	ans = [0] * n
	before = [101] * n
	index = 0
	while index < n:
		left = 0
		time2 = 0
		time2 += seq[index]
		for i in before:
			if i == 101:
				break
			if time2 + i > time:
				left += 1
			else:
				time2 += i
		ans[index] = left
		before[index] = seq[index]
		before.sort()
		index += 1
	return ans
(n, time) = list(map(int, input().split()))
seq = list(map(int, input().split()))
for x in solve(n, time, seq):
	print(x, end=' ')


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
from heapq import *
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	(n, m) = mp()
	l = li()
	ans = [0]
	pre = l[0]
	h = [-l[0]]
	for i in range(1, n):
		pre += l[i]
		cur = 0
		x = []
		s = 0
		while h and s < pre - m:
			a = heappop(h)
			x.append(a)
			s -= a
			cur += 1
		for j in x:
			heappush(h, j)
		heappush(h, -l[i])
		ans.append(cur)
	print(*ans)
for _ in range(1):
	solve()


(n, m) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
cnt = [0] * 101
curr = 0
for i in range(n):
	res = 0
	val = curr + arr[i] - m
	t = 100
	while t > 0 and val > 0:
		d = min(cnt[t], (val + t - 1) // t)
		res += d
		val -= d * t
		t -= 1
	print(res, end=' ')
	curr += arr[i]
	cnt[arr[i]] += 1


(n, m) = list(map(int, input().split()))
A = list(map(int, input().split()))
Sum = A[0]
S = [A[0]]
for val in A[1:]:
	Sum += val
	S.append(Sum)
for (val, R) in zip(S, range(n)):
	if val <= m:
		print(0, end=' ')
	else:
		count = 1
		Sorted = list(sorted(A[:R]))
		for i in range(R - 1, 0, -1):
			val -= Sorted[i]
			if val <= m:
				break
			count += 1
		print(count, end=' ')
print()


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l2 = []
b = []
for i in range(n):
	if sum(l[0:i + 1]) <= m:
		b.append(0)
	else:
		l2 = []
		l2.extend(l)
		c = 0
		d = sum(l2[0:i + 1])
		while d > m:
			e = max(l2[0:i - c])
			d -= e
			l2.remove(e)
			c += 1
		b.append(c)
for i in b:
	print(i, end=' ')


(n, M) = [int(i) for i in input().split()]
lst = [int(i) for i in input().split()]
a = list()
for j in range(n):
	temp = sorted(lst[:j])
	s = lst[j]
	count = 1
	for y in temp:
		if s + y > M:
			break
		s += y
		count += 1
	a.append(j + 1 - count)
print(*a)


(n, M) = input().split()
n = int(n)
M = int(M)
l = []
for x in input().split():
	l.append(int(x))
for i in range(n):
	if sum(l[:i + 1]) > M:
		x = sorted(l[:i])
		c = 0
		k = 0
		for j in range(i):
			k = k + x[i - 1 - j]
			c = c + 1
			if k >= sum(l[:i + 1]) - M:
				break
		print(c, end=' ')
	else:
		print(0, end=' ')


(n, m) = list(map(int, input().split()))
t = list(map(int, input().split()))
for i in range(n):
	s = sum(t[:i])
	li = sorted(t[:i])
	res = 0
	while s > m - t[i]:
		res += 1
		s -= li[-1]
		li.pop()
	print(res, end=' ')


a = []
total = 0

def binary_search(n, l):
	first = 0
	last = len(l) - 1
	found = False
	mid = (first + last) // 2
	while first <= last and (not found):
		mid = (first + last) // 2
		if l[mid] == n:
			found = True
		elif n < l[mid]:
			last = mid - 1
		else:
			first = mid + 1
	if found:
		return mid
	else:
		return first
(n, M) = map(int, input().split())
t = [int(x) for x in input().split()]
lena = 0
for x in t:
	rem = M - x
	if rem >= total:
		print('0', end=' ')
	else:
		count = 0
		while rem > 0:
			if a[count] <= rem:
				rem -= a[count]
				count += 1
			else:
				break
		print(lena - count, end=' ')
	a.insert(binary_search(x, a), x)
	total += x
	lena += 1


(n, M) = map(int, input().split())
arr = list(map(int, input().split()))
counter = [0] * 101
acc = 0
maxer = 0
for elem in arr:
	acc += elem
	temp = int(acc)
	ans = 0
	if acc <= M:
		pass
	else:
		flag = True
		for i in range(maxer, 0, -1):
			for j in range(counter[i]):
				if temp > M:
					temp -= i
					ans += 1
				else:
					flag = False
					break
			if not flag:
				break
	counter[elem] += 1
	maxer = max(maxer, elem)
	print(ans, end=' ')


(n, m) = map(int, input().split())
l = [int(i) for i in input().split()]
from math import ceil
from collections import defaultdict
freq = defaultdict(int)
sm = 0
for i in range(n):
	sm += l[i]
	cnt = 0
	if sm <= m:
		print(0, end=' ')
	else:
		rem = sm - m
		curr = 0
		cnt = 0
		for x in range(100, 0, -1):
			f = freq[x]
			if curr + f * x <= rem:
				curr += f * x
				cnt += f
			else:
				now = rem - curr
				cnt += ceil(now / x)
				curr = rem
				break
		print(cnt, end=' ')
	freq[l[i]] += 1


import math
import bisect
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = [a[0]]
sumi = a[0]
c = [0]
print(0, end=' ')
cnt = 0
for i in range(1, n):
	sumi += a[i]
	if sumi <= k:
		print(0, end=' ')
		c.append(0)
		bisect.insort(b, a[i])
	else:
		j = i - 1
		dupsum = sumi
		cnt = 0
		for l in range(j, -1, -1):
			dupsum -= b[l]
			cnt += 1
			if dupsum <= k:
				break
		print(cnt, end=' ')
		c.append(cnt)
		bisect.insort(b, a[i])


from itertools import accumulate
(n, m) = [int(el) for el in input().split()]
stud_times = [int(el) for el in input().split()]

def num_studs_to_remove(studs, save_time):
	num_studs = 0
	index = 0
	while index < len(studs):
		save_time -= studs[index]
		num_studs += 1
		index += 1
		if save_time <= 0:
			return num_studs
	return num_studs

def sol_c(times, max_time):
	cum_sums = list(accumulate(times))
	studs_to_remove = list()
	for i in range(len(times)):
		if cum_sums[i] <= max_time:
			studs_to_remove.append(0)
		else:
			time_to_save = cum_sums[i] - max_time
			studs_to_remove.append(num_studs_to_remove(sorted(times[:i], reverse=True), time_to_save))
	return ' '.join([str(el) for el in studs_to_remove])
print(sol_c(stud_times, m))


import math
import heapq
import copy
from collections import OrderedDict
from collections import deque
t = list(map(int, input().split()))
d = t[1]
k = list(map(int, input().split()))
m = []
heapq.heapify(m)
ans = list()
time = 0
for i in range(t[0]):
	time = time + k[i]
	if d - time >= 0:
		ans.append(0)
		heapq.heappush(m, -1 * k[i])
	else:
		nt = copy.copy(m)
		count = 0
		test = time
		while test > d:
			val = heapq.heappop(nt)
			val = val * -1
			test = test - val
			count = count + 1
		ans.append(count)
		heapq.heappush(m, -1 * k[i])
print(*ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	import math
	(n, m) = map(int, input().split())
	vals = list(map(int, input().split()))
	time = [0 for s in range(100)]
	ans = [0 for s in range(n)]
	count = 0
	for s in range(n):
		if vals[s] > m - count:
			people = 0
			cur = m - count
			ind = 99
			while vals[s] > cur and ind >= 0:
				if vals[s] <= cur + time[ind] * (ind + 1):
					diff = math.ceil((vals[s] - cur) / (ind + 1))
					people += diff
					cur += diff * (ind + 1)
				else:
					cur += time[ind] * (ind + 1)
					people += time[ind]
				ind -= 1
			ans[s] = people
		count += vals[s]
		time[vals[s] - 1] += 1
	print(*ans)
main()


def gns():
	return list(map(int, input().split()))
(n, m) = gns()
ns = gns()
dp = [0] * (m + 1)
for i in range(n):
	c = ns[i]
	print(i - dp[-c - 1], end=' ')
	dp2 = list(dp)
	for j in range(c, m + 1):
		dp[j] = max(dp[j], dp2[j - c] + 1)
print()


(n, M) = map(int, input().split())
ls = list(map(int, input().split()))
for i in range(n):
	temp = sorted(ls[:i])
	Sum = ls[i]
	cnt = 1
	for j in temp:
		if Sum + j > M:
			break
		Sum += j
		cnt += 1
	print(i + 1 - cnt, end=' ')
print()


(n, m) = [int(n) for n in input().split()]
l = list(map(int, input().split()))
sum = 0
i = 0
while i < len(l):
	sum += l[i]
	if sum <= m:
		print('0', end=' ')
		i += 1
	else:
		break
while i < len(l):
	l1 = l[0:i]
	l1.sort()
	j = len(l1) - 1
	sum2 = sum
	count = 0
	while j >= 0:
		if sum2 - l1[j] <= m:
			count += 1
			print(count, end=' ')
			break
		else:
			sum2 -= l1[j]
			j -= 1
			count += 1
	i += 1
	if i < len(l):
		sum += l[i]


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
ans = [0] * n
for i in range(1, n):
	(cur, remov) = (0, 0)
	b = sorted(a[:i], reverse=True)
	for j in range(len(b)):
		if m - sum(b[remov:]) >= a[i]:
			continue
		else:
			remov += 1
	ans[i] = remov
print(*ans)


(n, m) = map(int, input().split())
t = list(map(int, input().split()))
ans = [0]
summ = t[0]
for i in range(1, n):
	summ += t[i]
	if summ <= m:
		ans.append(0)
	else:
		d = summ - m
		t[:i] = list(sorted(t[:i]))
		j = i - 1
		while d > 0:
			d -= t[j]
			j -= 1
		ans.append(i - j - 1)
print(*ans)


(n, M) = list(map(int, input().split()))
t = list(map(int, input().split()))
ans = []
time_total = 0
for i in range(n):
	if t[i] <= M - time_total:
		time_total += t[i]
		ans.append(0)
	else:
		duplicate_time_total = time_total
		count = 0
		duplicate = t[:i]
		duplicate.sort(reverse=True)
		for j in duplicate:
			count += 1
			duplicate_time_total -= j
			if t[i] <= M - duplicate_time_total:
				break
		time_total += t[i]
		ans.append(count)
for i in ans:
	print(i, end=' ')


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
for x in range(a):
	if sum(c[:x + 1]) <= b:
		print(0, end=' ')
	else:
		t = 0
		p = c[:x]
		j = sum(c[:x + 1])
		p.sort(reverse=True)
		for y in range(len(p)):
			if j > b:
				j -= p[y]
				t += 1
			if j <= b:
				print(t, end=' ')
				break


(n, m) = map(int, input().split())
t = list(map(int, input().split()))
li = []
ans = []
for j in range(n):
	li = sorted(li)
	li.append(t[j])
	ruiseki = [0] * (len(li) + 1)
	for i in range(len(li)):
		ruiseki[i + 1] = ruiseki[i] + li[i]
	for i in range(len(ruiseki) - 1)[::-1]:
		if ruiseki[i] + t[j] <= m:
			ans.append(len(ruiseki) - i - 2)
			break
print(' '.join(map(str, ans)))


def array_sum(arr):
	arr_sum = 0
	for i in range(len(arr)):
		arr_sum += arr[i]
	return arr_sum
(n, M) = map(int, input().split())
t = list(map(int, input().split()))
ans = []
for i in range(n):
	t_f = t[:i]
	t_f = sorted(t_f)
	stud_count = 0
	for j in range(len(t_f)):
		if array_sum(t_f) + t[i] > M:
			t_f[-stud_count - 1] = 0
			stud_count += 1
		else:
			break
	ans.append(stud_count)
print(' '.join((str(i) for i in ans)))


import sys
import math
input = sys.stdin.readline
(n, M) = map(int, input().split())
arr = list(map(int, input().split()))
pre = [arr[0]]
for i in range(1, n):
	pre.append(pre[-1] + arr[i])
ans = [0]
for i in range(1, n):
	now = 0
	arr2 = list(arr[:i])
	arr2.sort()
	j = len(arr2) - 1
	while pre[i] > M:
		pre[i] -= arr2[j]
		j -= 1
		now += 1
	ans.append(now)
print(*ans)


import os
import heapq
import sys, threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10 ** 5)
from io import BytesIO, IOBase

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def power(x, p, m):
	res = 1
	while p:
		if p & 1:
			res = res * x % m
		x = x * x % m
		p >>= 1
	return res

def inar():
	return [int(k) for k in input().split()]

def lcm(num1, num2):
	return num1 * num2 // gcd(num1, num2)

def main():
	t = 1
	for _ in range(t):
		(n, m) = inar()
		arr = inar()
		freq = [0] * 101
		sm = 0
		for i in range(n):
			take = sm + arr[i] - m
			k = 0
			if take > 0:
				for j in range(100, 0, -1):
					value = j * freq[j]
					if value > take:
						k += (take + j - 1) // j
						break
					k += freq[j]
					take -= value
			sm += arr[i]
			freq[arr[i]] += 1
			print(k, end=' ')
		print()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math
(a, b) = map(int, input().split())
c = list(map(int, input().split()))
j = [0] * 101
m = 0
for x in range(a):
	m += c[x]
	if m <= b:
		print(0, end=' ')
		j[100 - c[x]] += 1
	else:
		l = 0
		f = m - b
		for y in range(101):
			if j[y] != 0:
				if f <= (100 - y) * j[y]:
					if f < 100 - y:
						l += 1
						print(l, end=' ')
						break
					else:
						l += math.ceil(f / (100 - y))
						print(l, end=' ')
						break
				else:
					l += j[y]
					f -= j[y] * (100 - y)
		j[100 - c[x]] += 1


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
temp = []
data = []
for i in range(1, n):
	temp.append(arr[i - 1])
	temp.sort()
	data.append(temp[:])
ans = [0] * n
for i in range(1, n):
	time = arr[i]
	x = data[i - 1]
	count = 0
	for j in x:
		if time + j <= m:
			time = time + j
			count += 1
		else:
			break
	ans[i] = len(x) - count
print(*ans)


from collections import defaultdict
from heapq import heappop, heappush
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
prefix = [l[0]]
for i in range(1, n):
	prefix.append(prefix[-1] + l[i])
ans = []
heap = []
for i in range(n):
	if prefix[i] <= m:
		ans.append(0)
		heappush(heap, -l[i])
	else:
		count = 0
		temp = []
		total = prefix[i]
		while heap and total > m:
			z = -heappop(heap)
			temp.append(z)
			total -= z
			count += 1
		ans.append(count)
		for j in temp:
			heappush(heap, -j)
		heappush(heap, -l[i])
print(*ans)


def run():
	a = input()
	b = input()
	(n, m) = list(map(int, a.split()))
	ts = list(map(int, b.split()))
	waiting = [0]
	for i in range(1, n):
		prev = ts[0:i]
		s = sum(prev) + ts[i]
		if s <= m:
			waiting.append(0)
			continue
		prev.sort()
		temp = 0
		while True:
			del prev[-1]
			temp += 1
			if sum(prev) + ts[i] <= m:
				break
		waiting.append(temp)
	print(' '.join(list(map(str, waiting))))
run()


R = lambda : map(int, input().split())
v = []
f = []
p = s = 0
(n, m) = R()
for i in R():
	s += i
	g = s
	while s > m:
		s -= f[-1 - p]
		p += 1
	s = g
	v.append(p)
	f.append(i)
	f.sort()
	p = 0
print(*v)


import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from itertools import accumulate, combinations, permutations
from operator import add
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
(n, k) = r()
arr = rr()
left = k
brr = list(accumulate(arr, add))
for (i, j) in enumerate(brr):
	if j <= k:
		print(0, end=' ')
	else:
		temp = sorted(arr[:i])[::-1]
		c = 0
		for x in temp:
			j -= x
			c += 1
			if j <= k:
				break
		print(c, end=' ')


(n, M) = list(map(int, input().split()))
t = list(map(int, input().split()))
a = []
for i in range(n):
	ti = sorted(t[:i])
	Mi = M - t[i]
	s = 0
	j = 0
	while j < i:
		s += ti[j]
		if s > Mi:
			break
		j += 1
	a.append(i - j)
print(*a)


def cumsum(a):
	b = []
	b.append(a[0])
	for i in range(1, len(a)):
		b.append(a[i] + b[i - 1])
	return b
(n, m) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = cumsum(a)
c = []
for (indx, i) in enumerate(b):
	if i <= m:
		c.append(0)
	else:
		d = cumsum(sorted(a[:indx]))
		c.append(indx - len([t for t in d if t <= m - a[indx]]))
for i in c:
	print(i, end=' ')
print()


(n, time) = map(int, input().split())
clock = 0
arr = [[0, 0]]
for elem in list(map(int, input().split())):
	clock += elem
	if clock <= time:
		print(0, end=' ')
	else:
		for i in range(1, len(arr)):
			if clock - arr[i][0] <= time:
				print(i, end=' ')
				break
	found = False
	for i in range(1, len(arr)):
		if arr[i][1] < elem:
			numbf = i
			znach = arr[i][1]
			news = arr[i][0] - arr[i][1] + elem
			arr[i][0] = news
			arr[i][1] = elem
			found = True
			break
	if found:
		for i in range(numbf + 1, len(arr)):
			arr[i][0] = arr[i - 1][0] + znach
			(arr[i][1], znach) = (znach, arr[i][1])
		arr.append([arr[len(arr) - 1][0] + znach, znach])
	else:
		arr.append([arr[len(arr) - 1][0] + elem, elem])


import heapq
(n, m) = map(int, input().split())
t = [int(o) for o in input().split()]
ts = 0
h = []
lol = []
for i in range(n):
	lol = []
	ts1 = ts
	nos = 0
	while ts1 + t[i] > m:
		k = heapq.heappop(h)
		ts1 += k
		lol.append(k)
		nos += 1
	while lol:
		k = lol.pop()
		heapq.heappush(h, k)
	heapq.heappush(h, -t[i])
	ts += t[i]
	print(nos, end=' ')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = []
ans = []
summ = 0
for i in a:
	summ += i
	sum1 = 0
	x = 0
	while summ - sum1 > m:
		sum1 += b[x]
		x += 1
	b.append(i)
	b.sort()
	b.reverse()
	ans.append(x)
print(*ans)


from sys import stdin
from collections import defaultdict, Counter
from bisect import bisect_left
from math import sqrt
from heapq import *

def iinput():
	return int(stdin.readline())

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))
t = 1
while t:
	t -= 1
	(n, m) = minput()
	a = linput()
	req = 0
	heap = []
	heapify(heap)
	fail = []
	cnt = 0
	for i in range(n):
		if req + a[i] <= m:
			req += a[i]
		else:
			temp = heap.copy()
			cnt = 0
			sm = req
			while sm + a[i] > m:
				sm += heappop(temp)
				cnt += 1
			req += a[i]
		heappush(heap, -1 * a[i])
		fail.append(cnt)
	print(*fail)


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
ans = []
counted = []
s = 0
for i in arr:
	c = 0
	s += i
	temp = s
	counted.sort()
	if s > m:
		z = -1
		while temp > m:
			temp -= counted[z]
			z -= 1
			c += 1
	counted.append(i)
	ans.append(c)
print(*ans)


arr = input()
(N, M) = [int(x) for x in arr.split(' ')]
arr = input()
arr = [int(x) for x in arr.split(' ')]
s = 0
freq = [0] * 101
for i in range(N):
	res = 0
	num = arr[i]
	s += num
	if s > M:
		tmp = s
		for k in range(100, 0, -1):
			d = tmp - M
			need = d // k + (d % k > 0)
			res += min(freq[k], need)
			tmp -= k * min(freq[k], need)
			if tmp <= M:
				break
	print(res, end=' ')
	freq[num] += 1


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
a = []
ans = []
for i in range(n):
	if a == []:
		a.append(l[i])
		ans.append(0)
	else:
		s = 0
		for j in range(i):
			s += a[j]
			if s + l[i] > m:
				ans.append(i - j)
				break
		else:
			ans.append(0)
		for j in range(i):
			if l[i] < a[j]:
				a.insert(j, l[i])
				break
		else:
			a.append(l[i])
for i in ans:
	print(i, end=' ')


(n, t) = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
anss = []
for i in range(1, n + 1):
	x = sorted(l[:i - 1], reverse=True)
	o = l[i - 1]
	ans = 0
	while sum(x) + o > t and len(x) > 0:
		x.remove(max(x))
		ans += 1
	anss.append(ans)
print(*anss)


def f(t, cnt):
	cnt1 = 0
	lt = sorted(c[:t], reverse=True)
	for i in range(len(lt)):
		cnt1 += lt[i]
		if cnt1 >= cnt:
			return i + 1
			break
(a, b) = map(int, input().split())
c = input().split()
c = [int(i) for i in c]
cnt = 0
stud = 0
for i in range(len(c)):
	cnt += c[i]
	if b < cnt:
		print(f(i, cnt - b), end=' ')
	else:
		print(0, end=' ')


(N, M) = map(int, input().split())
T = list(map(int, input().split()))
Q = []
sumi = 0
print(0)
for i in range(1, N):
	x = M - T[i]
	T1 = T[:i]
	T1.sort()
	sumi = sum(T1)
	while sumi > x:
		sumi -= T1.pop()
	print(i - len(T1))


def insert(a, x, k):
	temp = a[x[k]]
	value = x[k]
	j = k - 1
	while j >= 0 and a[x[j]] > temp:
		x[j + 1] = x[j]
		j -= 1
	x[j + 1] = value
	return x
(n, time) = map(int, input().split())
a = list(map(int, input().split()))
rez = [0] * n
count = 0
if a[0] > time:
	count += 1
rez[0] = count
b = [0] * n
for i in range(n):
	b[i] = i
for i in range(1, n):
	t = 0
	s = a[b[i]]
	while t < i and s + a[b[t]] <= time:
		s += a[b[t]]
		t += 1
	rez[i] = i - t
	b = insert(a, b, i)
for item in rez:
	print(item, end=' ')


(n, m) = map(int, input().split())
u = list(map(int, input().split()))
u1 = []
p = 0
for i in range(n):
	p += u[i]
	u1.append(p)
ans1 = []
for i in range(n):
	if u1[i] <= m:
		ans1.append('0')
		continue
	r = u[:i]
	r.sort(reverse=1)
	x = u1[i] - m
	ans = 0
	for j in range(len(r)):
		x -= r[j]
		ans += 1
		if x <= 0:
			break
	ans1.append(str(ans))
print(' '.join(ans1))


(n, m) = list(map(int, input().split()))
l = list(map(int, input().split()))
print(0, end=' ')
i = 1
for i in range(1, n):
	lp = sorted(l[:i])
	(j, p) = (0, 1)
	sum = l[i]
	while lp[j] + sum <= m and j < i:
		sum += lp[j]
		p += 1
		j += 1
		if j >= i:
			break
	print(i - j, end=' ')


o = input().rstrip().split(' ')
p = input().rstrip().split(' ')
l = []
q = []
w = []
S = []
D = []
X = 0
for i in range(0, len(p)):
	X += int(p[i])
	if X <= int(o[1]):
		print(0, end=' ')
		l.append(int(p[i]))
	else:
		C = 0
		j = 0
		D = X
		l.sort(key=int, reverse=True)
		while j < len(l):
			C += 1
			X -= int(l[j])
			if X <= int(o[1]):
				print(C, end=' ')
				break
			else:
				j += 1
		l.append(int(p[i]))
		X = D


import math
import heapq
import copy
from collections import OrderedDict
from collections import deque
t = list(map(int, input().split()))
d = t[1]
k = list(map(int, input().split()))
m = [0] * 101
ans = list()
time = 0
for i in range(t[0]):
	time = time + k[i]
	if d - time >= 0:
		ans.append(0)
		m[k[i]] = m[k[i]] + 1
	else:
		count = 0
		test = time
		for j in range(100, -1, -1):
			if test <= d:
				break
			if m[j] > 0:
				cur = m[j]
				vv = cur * j
				if abs(test - vv) <= d:
					if vv < test or vv > test:
						x = math.ceil((test - d) / j)
						if x <= cur:
							count = count + x
							test = test - x * j
						else:
							count = count + cur
							test = test - cur * j
					else:
						count = count
						test = test - vv
				else:
					count = count + m[j]
					test = test - vv
		ans.append(count)
		m[k[i]] = m[k[i]] + 1
print(*ans)


from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, groupby
import sys
import bisect
import string
import math
import time
import random

def S_():
	return input()

def LS():
	return [i for i in input().split()]

def I():
	return int(input())

def MI():
	return map(int, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def StoI():
	return [ord(i) - 97 for i in input()]

def ItoS(nn):
	return chr(nn + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def GI(V, E, Directed=False, index=0):
	org_inp = []
	g = [[] for i in range(n)]
	for i in range(E):
		inp = LI()
		org_inp.append(inp)
		if index == 0:
			inp[0] -= 1
			inp[1] -= 1
		if len(inp) == 2:
			(a, b) = inp
			g[a].append(b)
			if not Directed:
				g[b].append(a)
		elif len(inp) == 3:
			(a, b, c) = inp
			aa = (inp[0], inp[2])
			bb = (inp[1], inp[2])
			g[a].append(bb)
			if not Directed:
				g[b].append(aa)
	return (g, org_inp)

def bit_combination(k, n=2):
	rt = []
	for tb in range(n ** k):
		s = [tb // n ** bt % n for bt in range(k)]
		rt += [s]
	return rt

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = ['Yes', 'No']
mo = 10 ** 9 + 7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10 ** 5)
input = lambda : sys.stdin.readline().rstrip()

def ran_input():
	import random
	n = random.randint(4, 16)
	(rmin, rmax) = (1, 10)
	a = [random.randint(rmin, rmax) for _ in range(n)]
	return (n, a)
show_flg = False
show_flg = True
ans = 0
(n, m) = LI()
t = LI()
c = [0] * 101
T = 0
for i in range(n):
	R = T
	ans = 0
	for j in range(101)[::-1]:
		if m - (R - c[j] * j) >= t[i]:
			if t[i] - (m - R) > 0:
				ans += (t[i] - (m - R) + j - 1) // j
			print(ans)
			break
		ans += c[j]
		R -= c[j] * j
	T += t[i]
	c[t[i]] += 1


import bisect
tmp = input().split()
m = int(tmp[1])
ar = list(map(int, input().split()))
ar2 = list()
sum = 0
for i in ar:
	if sum + i > m:
		r = 0
		j = len(ar2) - 1
		while j >= 0 and m - sum + r < i:
			r += ar2[j]
			j -= 1
		print(len(ar2) - j - 1, end=' ')
	else:
		print(0, end=' ')
	bisect.insort(ar2, i)
	sum += i


import sys
from heapq import heappush, heappop
sys.setrecursionlimit(1000000)

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def next(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = self.next_line()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_line(self):
		return sys.stdin.readline().split()

	def next_ints(self):
		return [int(x) for x in sys.stdin.readline().split()]

	def next_int(self):
		return int(self.next())

	def solve(self):
		(n, m) = self.next_ints()
		t = self.next_ints()
		r = []
		s = 0
		b = 0
		h = []
		hh = []
		for v in t:
			while s + v > m:
				b += 1
				vv = -heappop(h)
				s -= vv
				heappush(hh, vv)
			r.append(b)
			heappush(hh, v)
			b += 1
			while len(hh) > 0 and s + hh[0] <= m:
				vv = heappop(hh)
				s += vv
				heappush(h, -vv)
				b -= 1
		print(' '.join((str(x) for x in r)))
Main().solve()


(n, m) = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
p = l.copy()
for i in range(1, n):
	l[i] += l[i - 1]
c = 0
s = 0
ans = []
for i in range(n):
	if l[i] > m:
		d = l[i] - m
		k = p[:i]
		k.sort(reverse=True)
		c = 0
		s = 0
		for e in k:
			if s < d:
				s += e
				c += 1
	ans.append(c)
ans = [str(x) for x in ans]
s = ' '.join(ans)
print(s)


from sys import stdout
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
dp = 0
size = max(a) + 1
b = [0] * size
for i in range(n):
	e = a[i]
	k = 1
	c = 0
	s_c = m - e
	while k < size:
		if b[k] != 0:
			if s_c < b[k] * k:
				c += s_c // k
				break
			else:
				s_c -= b[k] * k
				c += b[k]
		k += 1
	b[e] += 1
	stdout.write(str(i - c) + ' ')


(N, M) = map(int, input().split())
t = list(map(int, input().split()))
ansl = []
for i in range(N):
	a = t[i]
	d = sorted(t[:i])
	c = 0
	for j in range(i):
		a += d[j]
		c += 1
		if a > M:
			c -= 1
	ansl.append(i - c)
print(' '.join(map(str, ansl)))


R = lambda : map(int, input().split())
(n, M) = R()
L = list(R())
print(0, end=' ')
for i in range(1, n):
	su = sum(L[:i + 1])
	c = 0
	s = sorted(L[:i])
	j = i - 1
	while su > M:
		c += 1
		su -= s[j]
		j -= 1
	print(c, end=' ')


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(n, m) = f()
l = il()
print(0, end=' ')
sm = l[0]
for i in range(1, n):
	sm += l[i]
	if sm > m:
		sm1 = 0
		c = 0
		for j in sorted(l[:i], reverse=True):
			sm1 += j
			c += 1
			if sm - sm1 <= m:
				print(c, end=' ')
				break
	else:
		print(0, end=' ')


nM = input()
(n, M) = nM.split(' ')
n = int(n)
M = int(M)
arr = input()
arr = [int(x) for x in arr.split(' ')]
ans = [str(0)] * n
s = 0
for i in range(n):
	s += arr[i]
	tmp = s - arr[i]
	if s > M:
		prev = sorted(arr[:i], reverse=True)
		k = 0
		while tmp > M - arr[i] and k < i:
			tmp -= prev[k]
			k += 1
		ans[i] = str(k)
print(' '.join(ans))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
for i in range(len(a)):
	count = a[i]
	p = 0
	u = []
	for j in range(i):
		u.append(a[j])
		count += a[j]
	while count > k:
		x = max(u)
		count -= x
		u.remove(x)
		p += 1
	print(p, end=' ')


(n, m) = map(int, input().split())
arr = [int(x) for x in input().split()]
k = 0
arr2 = []
sumb = 0
for i in range(n):
	arr2.sort(reverse=True)
	suma = sumb
	tot = 0
	j = 0
	len1 = i
	while suma + arr[i] > m and j < len1:
		suma -= arr2[j]
		j += 1
		tot += 1
		if j == len1:
			break
	arr2.append(arr[i])
	sumb += arr[i]
	print(tot, end=' ')
print()


(n, M) = map(int, input().split())
print(0, end=' ')
a = [int(i) for i in input().split()]
pref = [0] * n
pref[0] = a[0]
for i in range(1, n):
	pref[i] = pref[i - 1] + a[i]
for i in range(1, n):
	now = a[:i]
	now.sort()
	k = 0
	A = M - pref[i]
	index = len(now) - 1
	while A < 0:
		A += now[index]
		index -= 1
		k += 1
	print(k, end=' ')


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
cnt = [0] * 101
s = 0
ans = []
for i in range(n):
	res = 0
	val = s + arr[i] - m
	t = 100
	while t > 0 and val > 0:
		d = min(cnt[t], (val + t - 1) // t)
		res += d
		val -= d * t
		t -= 1
	ans.append(res)
	s += arr[i]
	cnt[arr[i]] += 1
print(*ans)


(n, m) = map(int, input().strip().split())
a = [int(x) for x in input().strip().split()]
t = [0 for i in range(0, 101)]
for i in range(0, n):
	(c, j, s) = (a[i], 1, 0)
	flag = 0
	while j < 101:
		cnt = min(t[j], (m - c) // j)
		s += cnt
		c += j * cnt
		if cnt < t[j]:
			flag = 1
			break
		j += 1
	if flag == 0:
		print(0, end=' ')
	else:
		print(i - s, end=' ')
	t[a[i]] += 1


from heapq import *
(N, M) = map(int, input().split())
A = [int(a) for a in input().split()]
h = []
s = 0
k = 0
ANS = []
for a in A:
	t = []
	while s + a > M:
		t.append(heappop(h))
		s += t[-1]
	ANS.append(len(t) + k)
	while t:
		s -= t[-1]
		heappush(h, t.pop())
	s += a
	heappush(h, -a)
	if s > M:
		s += heappop(h)
		k += 1
print(*ANS)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
t = [0] * 101
si = 0
for i in range(n):
	(temp, k) = (si + l[i] - m, 0)
	if temp > 0:
		j = 100
		while j > 0:
			x = j * t[j]
			if temp <= x:
				k += (temp + j - 1) // j
				break
			k += t[j]
			temp -= x
			j -= 1
	si += l[i]
	t[l[i]] += 1
	print(k, end=' ')


(n, t) = map(int, input().split())
x = list(map(int, input().split()))
ans = []
for j1 in range(n):
	tem = []
	for i1 in range(j1):
		tem.append(x[i1])
	tem.sort()
	m = 0
	j = 0
	c = 0
	for i in range(j1):
		m += tem[i]
		c += 1
		if m > t - x[j1]:
			m -= tem[j]
			j += 1
			c -= 1
	ans.append(j1 - c)
print(*ans)


import math
import sys
(n, m) = map(int, input().split())
t = list(map(int, input().split()))
pt = [t[0]]
for i in range(1, n):
	pt.append(pt[-1] + t[i])
print(0, end=' ')
for i in range(1, n):
	if t[i] <= m - pt[i - 1]:
		print(0, end=' ')
	else:
		temp = sorted(t[:i], reverse=True)
		time = m - pt[i - 1]
		for j in range(i):
			time += temp[j]
			if t[i] <= time:
				print(j + 1, end=' ')
				break


nm = input().split()
n = int(nm[0])
m = int(nm[1])
t = input().split()
answer = []
sum_prev = 0
for i in range(n):
	sum_prev += int(t[i])
	number_removed = 0
	if sum_prev <= m:
		answer.append('0')
	else:
		t1 = list(map(int, t))
		sum_prev1 = sum_prev
		while sum_prev1 > m:
			j = i - number_removed
			sum_prev1 -= max(t1[0:j])
			t1.remove(max(t1[0:j]))
			number_removed += 1
		answer.append(str(number_removed))
print(' '.join(answer))


from sys import stdin
input = stdin.readline
(n, m) = map(int, input().split())
t = list(map(int, input().split()))
prev = m
for i in range(n):
	tmp = t[:i] + [0]
	tmp.sort()
	m = prev - t[i]
	j = 0
	while j < len(tmp) and m - tmp[j] >= 0:
		m -= tmp[j]
		j += 1
	c = len(tmp) - j
	print(c, end=' ')


import sys
input = sys.stdin.readline
(n, M) = map(int, input().split())
t = list(map(int, input().split()))
ans = []
tmp = [0] * 101
for i in range(n):
	num = 0
	T = t[i]
	for j in range(1, 101):
		if T + j * tmp[j] <= M:
			num += tmp[j]
			T += j * tmp[j]
		else:
			m = M - T
			num += m // j
			break
	ans.append(i - num)
	tmp[t[i]] += 1
print(*ans)


x = list(map(int, input().rstrip().split()))
y = list(map(int, input().rstrip().split()))
l = [0] * 101
out = [0] * x[0]
su = 0
for i in range(x[0]):
	k = 0
	d = su + y[i] - x[1]
	if d > 0:
		for j in range(100, 0, -1):
			h = j * l[j]
			if d <= h:
				k += (d + j - 1) // j
				break
			k += l[j]
			d -= h
	su += y[i]
	l[y[i]] += 1
	print(k)


(n, M) = map(int, input().split())
t = list(map(int, input().split()))
ans = []
for i in range(n):
	num = 0
	tmp = []
	T = 0
	for j in range(n):
		if i != j:
			tmp.append(t[j])
		else:
			T += t[i]
			break
	tmp = sorted(tmp)
	for j in range(len(tmp)):
		if T + tmp[j] <= M:
			T += tmp[j]
			num += 1
	ans.append(len(tmp) - num)
print(*ans)


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
s = 0
c = 0
b = []
for i in range(n):
	s += a[i]
	y = s
	if y > m:
		c = 0
		b.sort()
		r = len(b)
		while y > m:
			y -= b[r - 1]
			c += 1
			r -= 1
	b.append(a[i])
	print(c, end=' ')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
c = 0
for t in range(len(l)):
	c += l[t]
	if c <= m:
		print(0, end=' ')
	elif c > m:
		k = l[:t]
		k = sorted(k, reverse=True)
		x = c
		a = 0
		for i in k:
			x -= i
			a += 1
			if x <= m:
				print(a, end=' ')
				break


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
prefix_sum2 = [l[0]]
for i in range(1, n):
	prefix_sum2.append(prefix_sum2[-1] + l[i])
ans = [0]
for i in range(1, n):
	if prefix_sum2[i] <= m:
		ans.append(0)
	else:
		l1 = sorted(l[0:i], reverse=True)
		prefix_sum = [l1[0]]
		for j in range(1, len(l1)):
			prefix_sum.append(prefix_sum[-1] + l1[j])
		for j in range(len(prefix_sum)):
			if prefix_sum2[i] - prefix_sum[j] <= m:
				ans.append(j + 1)
				break
print(*ans)


def main1():
	buf = input()
	buflist = buf.split()
	n = int(buflist[0])
	M = int(buflist[1])
	buf = input()
	buflist = buf.split()
	t = list(map(int, buflist))
	student = []
	minimum = []
	for i in range(n):
		count = 0
		pointer = 0
		while pointer < i:
			if count + student[pointer] <= M - t[i]:
				count += student[pointer]
				pointer += 1
			else:
				break
		minimum.append(i - pointer)
		student.append(t[i])
		student.sort()
	print(' '.join(list(map(str, minimum))))

def main2():
	buf = input()
	buflist = buf.split()
	n = int(buflist[0])
	M = int(buflist[1])
	buf = input()
	buflist = buf.split()
	t = list(map(int, buflist))
	bucket = []
	for i in range(101):
		bucket.append(0)
	minimum = []
	for i in range(n):
		target = M - t[i]
		count = 0
		subtotal = 0
		for j in range(1, 101):
			if subtotal + bucket[j] * j > target:
				count += (target - subtotal) // j
				break
			else:
				count += bucket[j]
				subtotal += bucket[j] * j
		minimum.append(i - count)
		bucket[t[i]] += 1
	print(' '.join(list(map(str, minimum))))
main2()


from sys import setcheckinterval, stdin
setcheckinterval(1000)
iin = lambda : int(stdin.readline())
lin = lambda : list(map(int, stdin.readline().split()))
(n, m) = lin()
a = lin()
tempa = []
sm = 0
sol = []
for i in range(n):
	x = sorted(a[:i])
	if sm + a[i] > m:
		sm1 = 0
		ch = 0
		for j in range(i - 1, -1, -1):
			ch += 1
			sm1 += x[j]
			if sm + a[i] - sm1 <= m:
				break
		sol.append(ch)
	else:
		sol.append(0)
	sm += a[i]
print(*sol)


import math
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
dp = 0
s = 0
b = [0] * 101
for i in range(n):
	e = a[i]
	if s + e > m:
		k = 0
		c = 0
		s_c = s
		if i == n - 1:
			i = n - 1
		while s_c + e > m:
			if b[100 - k] != 0:
				t = math.ceil((s_c + e - m) / (100 - k))
				mul = min(t, b[100 - k])
				s_c -= (100 - k) * mul
				c += mul
			k += 1
		dp = c
	s += e
	b[e] += 1
	print(dp, end=' ')


(n, m) = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
s = 0
for i in range(n):
	s += t[i]
	count = 0
	if s > m:
		curr = s
		for j in sorted(t[:i], reverse=True):
			if curr > m:
				count += 1
				curr -= j
			else:
				break
	print(count, end=' ')


(a, b) = map(int, input().split())
z = list(map(int, input().split()))
s = 0
for i in range(a):
	s += z[i]
	if s > b:
		s1 = s
		k = sorted(z[:i], reverse=True)
		j = 0
		while s1 > b:
			s1 -= k[j]
			j += 1
		print(j)
	else:
		print(0)


(n, m) = map(int, input().split())
list1 = [int(x) for x in input().split()]
sum = 0
list2 = []
for item in list1:
	list2.append(item)
	sum = sum + item
	if sum <= m:
		print(0, end=' ')
	else:
		count = 0
		sum1 = item
		for i in list2[:len(list2)]:
			sum1 = sum1 + i
			if sum1 > m:
				break
			count = count + 1
		print(len(list2) - count - 1, end=' ')
	list2.sort()


import copy
(n, m) = map(int, input().split())
T = list(map(int, input().split()))
X = [0]
s = 0
for i in T:
	s = s + i
	X.append(s)
Y = []
Z = 0
for i in range(n):
	D = X[i + 1]
	L = copy.deepcopy(T[:i])
	j = 0
	while D > m and len(L):
		Z = max(L)
		D = D - Z
		L.remove(Z)
		j = j + 1
	Y.append(j)
for i in Y:
	print(i, end=' ')


from sys import stdin, stdout

def main():
	(n, m) = stdin.readline().split()
	n = int(n)
	m = int(m)
	arr = [int(i) for i in stdin.readline().split()]
	new = [0] * n
	sum = 0
	for i in range(n):
		sum += arr[i]
		if sum <= m:
			new[i] = 0
		else:
			new_arr = arr[:i]
			new_arr = sorted(new_arr)
			count = 0
			stud = 0
			j = len(new_arr) - 1
			while j >= 0:
				count += new_arr[j]
				stud += 1
				if count >= sum - m:
					new[i] = stud
					break
				else:
					j -= 1
	s = ''
	for i in range(len(new)):
		s = s + str(new[i]) + ' '
	stdout.write(s)
main()


a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * a[0]
c[0] = b[0]
for i in range(1, a[0]):
	c[i] = c[i - 1] + b[i]
for i in range(a[0]):
	if c[i] <= a[1]:
		print(0, end=' ')
	else:
		p = 0
		j = i - 1
		s = c[i]
		k = b[:i].copy()
		k.sort()
		while j >= 0 and s > a[1]:
			s = s - k[j]
			j -= 1
			p += 1
		print(p, end=' ')


import sys, math, string
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
(n, m) = M()
l = L()
a = [0]
for i in range(1, n):
	k = l[:i]
	k.sort()
	s = l[i]
	w = 0
	for p in range(len(k)):
		if s + k[p] <= m:
			s += k[p]
			w += 1
		else:
			break
	a.append(i - w)
print(*a)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = []
for i in range(n):
	if sum(a[:i + 1]) <= m:
		ans.append(0)
		continue
	else:
		x = a[i]
		j = 1
		while True:
			b = a[:i]
			b.sort()
			if sum(b[:j]) + x <= m:
				j += 1
				continue
			else:
				y = i + 1 - j
				ans.append(y)
				break
print(' '.join((str(r) for r in ans)))


(n, time) = input().split()
n = int(n)
time = int(time)
a = input().split()
a = [int(i) for i in a]
for i in range(n):
	temp = a[:i]
	temp.sort()
	count = 0
	while sum(temp) + a[i] > time:
		temp = temp[:len(temp) - 1]
		count += 1
	print(count, end=' ')


(n, m) = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
for i in range(n):
	q = m - t[i]
	w = t[:i]
	e = sum(w)
	if e > q:
		w.sort(key=lambda x: -x)
		cnt = 0
		ind = 0
		while e > q:
			e -= w[ind]
			cnt += 1
			ind += 1
		print(cnt, end=' ')
	else:
		print(0, end=' ')


(n, M) = map(int, input().split())
T = list(map(int, input().split()))
Ans = []
for i in range(n):
	if i == 0:
		if T[i] <= M:
			Ans.append(0)
	elif i == 1:
		if T[1] + T[0] <= M:
			Ans.append(0)
		elif T[1] <= M or T[0] <= M:
			Ans.append(1)
		else:
			Ans.append(2)
	else:
		sum = 0
		for k in range(i + 1):
			sum = sum + T[k]
		if sum <= M:
			Ans.append(0)
		else:
			o = 0
			Tl = T[0:i]
			Tp = sorted(Tl, reverse=True)
			while sum > M:
				sum = sum - Tp[o]
				o = o + 1
			Ans.append(o)
print(*Ans)


import heapq as h
(n, m) = [int(i) for i in input().split()]
heap = []
h.heapify(heap)
data = [int(i) for i in input().split()]
sm = 0
fails = 0
failed = []
h.heapify(failed)
for d in data:
	sm += d
	while sm > m:
		mx = -h.heappop(heap)
		h.heappush(failed, mx)
		sm -= mx
		fails += 1
	print(fails)
	if fails > 0 and d > failed[0]:
		f0 = h.heapreplace(failed, d)
		sm += f0 - d
		h.heappush(heap, -f0)
		while failed[0] + sm < m:
			f0 = h.heappop(failed)
			fails -= 1
			sm += f0
			h.heappush(heap, -f0)
	else:
		h.heappush(heap, -d)


(n, m) = map(int, input().split())
t = [int(e) for e in input().split()]
for i in range(n):
	notAll = False
	time = t[i]
	prev = [int(t[j]) for j in range(i)]
	prev.sort()
	for j in range(i):
		if time + prev[j] <= m:
			time += prev[j]
		else:
			notAll = True
			print(i - j, end=' ')
			break
	if notAll == False:
		print(0, end=' ')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
add = 0
i = 0
while add < m and i < n:
	if add + l[i] <= m:
		add += l[i]
		i += 1
	else:
		break
ans = [0] * i
if i == 0:
	ans = []
for j in range(i, n):
	x = l[:j]
	x.sort(reverse=True)
	y = sum(x)
	cnt = 0
	k = 0
	while y + l[j] > m:
		y -= x[k]
		k += 1
		cnt += 1
	ans.append(cnt)
print(*ans)


import heapq
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
s = 0
h = []
for i in range(n):
	if arr[i] + s <= m:
		print(0, end=' ')
	else:
		heapq._heapify_max(h)
		temp = []
		temp += h
		ind = 0
		temp_s = s
		while temp_s + arr[i] > m:
			temp_s -= temp[0]
			heapq._heappop_max(temp)
			ind += 1
		print(ind, end=' ')
	h.append(arr[i])
	s += arr[i]


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
count = [0] * 101
s = 0
res = list()
for i in a:
	if i + s <= t:
		res.append(0)
	else:
		d = i + s - t
		ct = 0
		for j in range(100, 0, -1):
			if count[j] > 0:
				m = min(count[j], math.ceil(d / j))
				ct += m
				d -= m * j
			if d <= 0:
				break
		res.append(ct)
	count[i] += 1
	s += i
print(*res)


(a, b) = input().split()
num_stud = int(a)
exam_time = int(b)
listc = list(map(int, input().split()))
result = [0 for i in range(num_stud)]
for i in range(num_stud):
	test_list = sorted(listc[0:i])
	if exam_time - sum(test_list) - listc[i] >= 0:
		result[i] = 0
	elif exam_time - sum(test_list) - listc[i] < 0:
		n = exam_time - sum(test_list) - listc[i]
		need = 0
		for j in range(1, len(test_list) + 1):
			subtract = test_list[-j:len(test_list)]
			if n + sum(subtract) >= 0:
				need += 1
				break
			elif n + sum(subtract) < 0:
				need += 1
				continue
		result[i] = need
for i in range(len(result)):
	result[i] = str(result[i])
solution = ' '.join(result)
print(solution)


from collections import Counter

def each(total, M, ocounter, student):
	counter = ocounter.copy()
	cnt = 0
	while total > M:
		m = max(counter)
		total -= m
		counter[m] -= 1
		if counter[m] <= 0:
			del counter[m]
		cnt += 1
	else:
		return cnt

def main():
	(n, M) = [int(x) for x in input().split()]
	students = [int(x) for x in input().split()]
	counter = Counter()
	result = []
	total = 0
	cnt = 0
	for student in students:
		total += student
		result.append(each(total, M, counter, student))
		counter[student] += 1
	print(' '.join([str(x) for x in result]))
main()


(n, m) = [int(x) for x in input().split()]
ti = [int(x) for x in input().split()]
op = ''
numsum = 0
for i in range(len(ti)):
	numsum = numsum + ti[i]
	if numsum <= m:
		op = op + str(0) + ' '
	else:
		nc = numsum
		subset = ti[:i]
		subset.sort()
		count = 0
		while nc > m:
			nc = nc - subset.pop()
			count += 1
		op = op + str(count) + ' '
op.rstrip()
print(op)


(n, m) = list(map(int, input().split()))
if n == 1:
	print(0)
	exit(0)
t = list(map(int, input().split()))
x = []
for i in range(len(t)):
	br = 0
	s = 0
	for j in range(len(x)):
		s += x[j]
		br = j
		if s > m - t[i]:
			break
	if s <= m - t[i]:
		print(0, end=' ')
	else:
		print(len(x) - br, end=' ')
	x.append(t[i])
	x.sort()


l = input().split()
n = int(l[0])
m = int(l[1])
l = input().split()
li = [int(i) for i in l]
print(0, end=' ')
for i in range(1, n):
	rem = m - li[i]
	z = list(li[:i])
	z.sort()
	count = 0
	for j in range(i):
		if z[j] <= rem:
			rem -= z[j]
			count += 1
		else:
			break
	print(i - count, end=' ')