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

answer = 0

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