N,X=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
b=0
if X<min(a):
    print(0)
else:
    for i in range(0,N):
        if X>=a[i]:
            X=X-a[i]
            b+=1
        else:
            break
    if X!=0:
        print(b-1)
    else:
        print(b)