from sys import stdin
N,x=[int(x) for x in stdin.readline().rstrip().split()]
data=[int(x) for x in stdin.readline().rstrip().split()]
data=sorted(data)
ans=0
if data[0] > x:
    print(0)
else:
    for i in data:
        x=x-i
        if x < 0:
            break
        ans+=1
    if x!=0 and ans !=1:
        ans-=1
    print(ans)