N, x = map(int,input().split())
A = list(map(int,input().split()))
A.sort
ans = 0
for i in range(len(A)):
    x = x-A[i]
    if x >= 0:
        ans += 1
    else:
        break
if x > 0:
    ans -= 1
print(ans)