import sys
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
if(a[0] > x):
    print(0)
    sys.exit()
for i in range(0,len(a)+1):
    if sum(a[0:i]) >= x:
        print(i)
        sys.exit()
print(len(a)-1)

