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

answer = 0
id = -1

for idx, a in enumerate(sorted(li_a)):
    id = idx
    if x >= a:
        answer += 1
        x -= a
    else:
        break
if x == 0 or answer == 0:
    print(answer)
else:
    if id == (n -1):
        print(answer - 1)
    else:
        print(answer)

