parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n,x = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	a = sort(a)
	count = 0
	for i in 1:n
		if x<a[i]
			break
		else
			count += 1
			x -= a[i]
		end
	end
	println(count)
end
main()