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