N,x=map(int,input().split())
C=sorted(list(map(int,input().split())))
num=0
if sum(C)==x:
    print(N)
    exit()
elif sum(C)>x:
    print(N-1)
    exit()
for i in range(N):
    if C[i]>x:
        print(i)
        exit()
    else:
        x-=C[i]
