N,X=map(int,input().split())
ai=list(map(int,input().split()))
ai.sort()
ans=0
for i in range(N):
    if ai[i] <= X:
        X = X -ai[i]
        ans= ans +1
    else:
        break
if X !=0 and ans!=0:
    ans = ans-1
print(ans)
