local N, x = io.read("*n", "*n")
local A = {}
for i = 1, N do
    A[i] = io.read("*n")
end
table.sort(A)

local counter = 0
for i = 1, N do
    if x - A[i] >= 0 then
        x = x - A[i]
        counter = counter + 1
    end
end
print(counter)