n,x=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]

a.sort()
ans=n
s=0
for i in range(n):
    if s>x:
        ans=i
        break
    else:
        s=s+a[i]
if s<x:
    print(ans-1)
else:
    print(ans)