N,X=map(int,input().split())
ai=list(map(int,input().split()))
ai.sort()
sum_of_the_candy=0
ans=0
if sum(ai)==X:
	ans=N
elif sum(ai)<X:
	ans=N-1
else:
	for i in range(N):
		sum_of_the_candy=sum_of_the_candy+ai[i]
		if sum_of_the_candy < X:
			ans = ans +1
		else:
			break
print(ans)