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