N,x = map(int,input().split())
A = sorted(list(map(int,input().split())))
ans = 0
for i,a in enumerate(A):
    x = x-a
    if x<0:
        break
    elif i==len(A)-1:
        if x!=a:
            break
    ans+=1
print(ans)