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

A.sort()
ct = 0
for i in range(n):
    if x>=A[i]:
        ct+=1
        x -= A[i]
    else:
        break
if x!=0 and i==n-1:
    ct-=1
print(ct)
