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

A.sort()
RA = []
q = 0
for i in range(n):
    q += A[i]
    RA.append(q)

if RA[-1] < x:
    ans = n - 1
elif RA[-1] == x:
    ans = n
elif RA[0] > x:
    ans = 0
else:
    for i in range(n):
        if RA[i] >= x:
            ans = i + 1
            break

print(ans)
