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

a.sort()

if x < a[0]:
	print(0)
	exit()

cnt = 0
for i in range(n):
	if a[i] <= x:
		cnt += 1
		x -= a[i]

if x > 0:
	print(cnt - 1)
else:
	print(cnt)
