
n = io.read("*n")
x = io.read("*n")
s = {}
for i = 1, n do
	s[i] = io.read("*n")
end
table.sort(s)
ret = 0
for i = 1, n do
	if x >= s[i] then
		x = x - s[i]
		ret = ret + 1
	else
		break
	end
end
if x > 0 and ret > 0 then
	ret = ret - 1
end
print(ret)