local function lltonumber(str)
  local ret = 0LL
  local sign = str:sub(1, 1) ~= "-"
  local begin = sign and 1 or 2
  for i = begin, #str do
    ret = ret * 10LL
    ret = ret + tonumber(str:sub(i, i))
  end
  if not sign then ret = ret * -1LL end
  return ret
end

local function llprint(llnumber)
  local str = tostring(llnumber):gsub("LL", "")
  print(str)
end

local str = io.read()
local n, kstr = str:match("(%d+) (%d+)")
n = tonumber(n)
local k = lltonumber(kstr)
local a, f = {}, {}
local asum = 0LL
for i = 1, n do
  a[i] = 0LL + io.read("*n")
  asum = asum + a[i]
end
for i = 1, n do
  f[i] = 0LL + io.read("*n")
end
table.sort(a)
table.sort(f, function(x, y) return x > y end)
if asum <= k then
  print(0)
else
  local function solve(x)
    local cnt = 0LL
    for i = 1, n do
      local c = x / f[i]
      if c < a[i] then
        cnt = cnt + a[i] - c
      end
    end
    return cnt <= k
  end
  local min = 0LL
  local max = a[1] * f[1]
  for i = 2, n do
    if max < a[i] * f[i] then max = a[i] * f[i] end
  end
  while 1LL < max - min do
    local mid = (min + max) / 2LL
    if solve(mid) then
      max = mid
    else
      min = mid
    end
  end
  llprint(max)
end
