
l1 = input().split()
l2 = input().split()

n = int(l1[0])
a = int(l1[1])
l2.sort()

i = 0
out = 0

for i in range(0,n):
    a = a - int(l2[i]) 
    if a >= 0:
        out = out + 1
    
print(out)    

