n, x = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)
ans = 0
for a in A:
    if x - a >= 0:
        x -= a
        ans += 1
if 0 < x:
    for a in A:
        x -= a
        ans -= 1
        if x <= 0:
            break

print(max(ans, 0))