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