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

count = 0

for a in A:
    if X - a < 0:
        break
    else:
        X -= a

    count += 1

if X > 0 and count > 1:
    count -= 1

print(count)
