function split(str,sep)
	local ret = {}
	local pos = 0
	while true do
		local pp = string.find(str,sep,pos+1)
		if pp == nil then
			table.insert(ret,string.sub(str,pos+1))
			break
		else
			table.insert(ret,string.sub(str,pos+1,pp-1))
			pos = pp
		end
	end
	return ret
end
a = io.read()
t = split(a, " ")
n, x = tonumber(t[1]), tonumber(t[2])
b = io.read()
t = split(b, " ")
s = {}
for i = 1, n do
	s[i] = tonumber(t[i])
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)
