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

child = 0
candy = 0

print(a)

for i in a:
    candy += i
    if candy <= x:
        child += 1

if sum(a) < x:
    child -= 1

print(child)