a = map(int, raw_input().split())
b = map(int, raw_input().split())

b.sort()
b.reverse()

snu = a[1]

c = 0
for i in b:
    if i <= snu:
        snu-=i
        c+=1

if snu!=0 and c!=0:
    c-=1

print(c)