N, x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

count = 0
ans = 0
for i in a:
	print(x)
	if x >= i:
		x = x - i
		ans += 1
	else:
		break
else:
	if x:
		ans -= 1

print(ans)
