N,x=[int(i) for i in input().split()]
a = [int(x) for x in input().split()]
a.sort()
cnt=0
if sum(a)<0:
	cnt -=1
for k in range(1,N):
		if x >= a[k]:
			cnt +=1
			x -= a[k]
		else:
			break
print(cnt)