N,x=map(int,input().split())
l=list(map(int,input().split()))
ans=0
l.sort()

for n in range(N):
    if l[n]<x:
        x-=l[n]
        ans+=1
    elif l[n]==x:
        x-=l[n]
        ans+=1
        break
    else:
        break

print(ans)