from itertools import accumulate

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

def f(B, x):
    ans = 0
    for b in B:
        ans += 1
        if x == b:
            break
        elif x < b:
            ans -= 1
            break
    return ans

if B[-1] < x:
    x -= B[-1]
    ans = len(A) - f(B, x)
else:
    ans = f(B, x)

print(ans)