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

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


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