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

A.sort()

count = 0
for i in range(N):
    count += A[i]
    if count > x:
        break

print(i + 1 if i >= N - 1 else i)