N, x = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

A.sort()

ans = 0
for a in A:
    if a <= x:
        ans += 1
        x -= a
    else:
        break
if x > 0:
    ans = max([ans - 1, 0])

print(ans)