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

s = list(map(int,input().split()))
s.sort()

count = 0
for i in range(N):
	if k - s[i] >= 0:
		count += 1
		k -= s[i]
	if 0 > k:
		break

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