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
---
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 time = {}
for i=1,N do
    time[i] = A[i] * F[i]
end

local function find_min_true()
    local ceil = math.ceil
    local max = math.max
    local function possible(max_time)
        local kk = K
        for i=1, N do
            kk = kk - max(ceil((time[i] - max_time) / F[i]), 0)
            if kk < 0 then
                return false
            end
        end
        return true
    end
    local left = -1
    local right = upper_lim
    while right - left > 1 do
        local m = left + (right - left) // 2
        if possible(m) then
            right = m
        else
            left = m
        end
    end
    return right
end

print(find_min_true())
