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

for i in range(0, N):
	x -= a_new[i]
	if x < 0:
		index = i - 1
		break
	if x == 0:
		index = i + 1
		break
	index = i

if index < 0:
	index = 0

print(str(index))