n,x=map(int,input().split())

a=list(map(int,input().split()))

a.sort()

s=0
i=0

if sum(a)<=x:
    print(n)
    exit()
elif min(a)>x:
    print(0)
    exit()
else:
    while s<=x:
        s+=a[i]
        i+=1

print(i-1)
