local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
--
local function find_min_true(n, f)
    -- Define f(-1) == false, f(n) == true
    -- Invariant: f(left) == false and f(right) == true
    local left = -1
    local right = n
    while right - left > 1 do
        local m = left + (right - left) // 2
        if f(m) then
            right = m -- keep f(right) == true
        else
            left = m -- keep f(left) == false
        end
    end
    return right
end
---
local N, K = read.nn()
local A = read.N(N)
local F = read.N(N)
table.sort(A)
table.sort(F, function(x,y)return x>y end)
local upper_lim = A[N] * F[1]

local function possible(max_time)
    local kk = K
    for i=1, N do
        local time = A[i] * F[i]
        if time > max_time then
            local train_cost = math.ceil((A[i] * F[i] - max_time) / F[i])
            kk = kk - train_cost
            if kk < 0 then
                return false
            end
        end
    end
    return true
end
print(find_min_true(upper_lim, possible))
