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

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



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