n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
s=[]
for i in range(n):
    if x>=0:
        x-=a[i]
        if x<0:
            b=i
    else:
        b=i
        break
#print(x)
if x>0:
	print(n-1)
elif x==0:
	print(n)
else:
	print(b)