from itertools import accumulate

N, x = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

A.sort()

count = 0
for a in A:
    x -= a
    if a < 0:
        break
    count += 1
print(count - (x > 0))