n = io.read()
x = io.read()
local a = {}
local sum = 0
local result = 0
for i=1,n do
	a[i] = io.read()
end


for i=1,n-1 do
	for j=i+1 ,n do
		if a[i] > a[j] then
			a[i],a[j] = a[j],a[i]
		end
	end
end

for i=1,n do
	if sum + a[i] <= x then
		sum = sum + a[i]
		result = result + 1
	end
end

print(result)