def cand(amari, a, count):
    #print("first", amari, a, count)
    if len(a)!=0:
        ma=max(a)
        a.remove(ma)
    else:
        print(count)
        exit()
    if amari>=ma:
        amari-=ma
        count+=1
        if len(a)==0 and amari!=0:
            count-=1
        #print("111", amari, ma, a, count)
        cand(amari, a, count)
    else:
        cand(amari, a, count)




[n, x]=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
count=0
cand(x, a, count)
