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

A=list(map(int, input().split()))
A.sort()

cnt=0
for a in A:
    if x < a or x <= 0:
        break
    else:
        x-=a
        cnt+=1
        
if 0 < x and 0 < cnt:
    cnt-=1

print(cnt)