n,x = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
cnt=0
for i,X in enumerate(a):
    if x>=X:
        cnt+=1
        x-=X
    else:
        break
if cnt>0 and x>0:
    cnt-=1
print(cnt)