n,x = list(map(int, input().split()))
a = list(map(int, input().split()))
a = sorted(a)
k = 0
for e,i in enumerate(a):
    x -= i
    if x == 0:
        k = e+1
        break
    elif x < 0:
        if e == 0:
            k = e
        else:
            k = e+1
        break
else:
    k = n-1
print(k)