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

a.sort()

count = 0
resid = x
for i in range(N):
    if a[i] <=resid:
        count += 1
        resid -= a[i]
    else:
        break
if resid > 0:
    count -= 1
print(max(count,0))