local read = io.read
local N, x = read("*n", "*n")
local a = {}

local sum = 0
for i = 1, N do
	a[i] = read("*n")
	sum = sum + a[i]
end
if sum == x then
	print(N)
	os.exit()
end
sum = nil

local out = 0
table.sort(a)
for i = 1, N do
	local pre_x = x - a[i]
	if pre_x < 0 then
		out = i - 1
		break
	elseif i == N then
		out = N - 1
		break
	end
	x = pre_x
end

print(out)
