N, x = map(int, input().split())
a=list(map(int, input().split()))

b = 0
c = 0
a.sort()
if x < a[0]:
    print(0)
    quit()  
elif sum(a)<x:
    print(N-1)
    quit()
else:
    for i in range(N):
        if c < x:
            b+=1
            c+=a[i]
            
print(b) 