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

#a_sort = sorted(a, reverse=True)
a_sort = sorted(a)
#print(a_sort)
manzoku =0
for n,i in enumerate(a_sort):
    if x>=i:
        #print(x,i)
        x-=i
        #print(x)
        manzoku+=1

#print(manzoku)
#print(x)
if (x>0) and (manzoku>0):
    print((manzoku)-1)
else:
    print(manzoku)
