N,x=map(int,input().split())
A=list(map(int,input().split()))
A_1=sorted(A)
num=0
total=0
if A[0]>x:
    num=0
elif sum(A_1)>=x:
    for i in range(N):
        total+=A_1[i]
        if total==x:
            num+=1
            break
        elif total>x:
            num-=1
            break
        else:
            num+=1

else:
    num=N-1
print(num)