N,k = map(int,input().split())

s = list(map(int,input().split()))
s.sort()
print(s)
count = 0
for i in range(N):
	if k - s[i] >= 0:
		count += 1
		k -= s[i]
	else:
		break

if count == N :
	if k>0:
		count -= 1
	print(count)
else:
	print(count)