local N = io.read("*n")
io.read()
local x = io.read("*n")
io.read()
local array = {}
for i=1,N do
    local like = io.read("*n")
    io.read()
    table.insert(array,like)
end

local function Test(x,array)
    table.sort(array,function (a,b)
        return a<b
    end)
    local total = 0
    for i=1,#array do
        total = total + array[i]
        if total > x then
            return i - 1
        end
    end
    return #array
end
print(Test(x,array))