from itertools import accumulate

N, x, *A = map(int, open(0).read().split())
A.sort()
B = list(accumulate(A)) # cumsum

ans = 0
for i in range(len(B)):
    ans = i
    if x == B[i]:
        ans += 1
        break
    elif x < B[i]:
        ans -= 1
        break

if ans < 0:
    ans = 0
print(ans)