N,x=[int(i) for i in input().split()]
a=[int(i) for i in  input().split()]
a = sorted(a)
res=0
for num in a:
    if num<=x:
        x-=num
        res+=1
    else:
        break
if x != 0 and res>0:
    res-=1
print(res)
