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

a_sort = sorted(a)
ans = 0
for i in range(0,N):
	if x > sum(a_sort[:i:]):
		ans += 1
		
if ans == N and x > sum(a_sort):
	ans -= 1
if x < a_sort[0]:
	ans = 0
print(ans)