N, x = map(int, input().split())
a = list(map(int, input().split()))
dp = [[]]
a.sort()
ans = 0
f = False
for b in a:
    if b <= x:
        ans += 1
        x -= b
        f = True
    else:
        f = False
if b > 0 and f:
    ans -= 1
print(ans)
