N,x=map(int,input().split())
child = [int(i) for i in input().split()]
child.sort()
count=0
for i in child:
    if(x>=i):
        x-=i
        count+=1
    if(x<=0):
        break
if(x>0):
    if(count!=0):
        count-=1
print(count)