n,x = map(int, input().split())
A = sorted(list(map(int, input().split())))
ans = 0
if A[0] > x:
    print(ans)
    exit()

for a in A:
    if a <= x:
        ans += 1
        x -= a
if x > 0: ans -= 1
print(ans)