import sys

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

ans = 0
for e in a:
    ans += 1
    x -= e
    if x <= 0:
        print(ans)
        sys.exit()

print(ans - 1)
