n,x=[int(k) for k in raw_input().split(" ")]

a=[int(k) for k in raw_input().split(" ")]

a=sorted(a)

nbh=0

for i in a:
    if i<=x:
        x-=i
        nbh+=1
    else:
        break
if x and nbh==n:
    nbh-=1

print nbh
