_, X = map(int, input().split())
A = sorted(list(map(int, input().split())))

count = 0
for a in A:
    if X - a >= 0:
        X -= a
        count += 1
else:
    if count > 0 and X > 0:
        count -= 1

print(count)