N, X = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]

count = 0
for i, a in enumerate(sorted(A)):
    if X >= a:
        count += 1
        X -= a
    
    if i == N - 1 and X > 0:
        count -= 1

print(count)
