N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort.reverse
F = gets.split.map(&:to_i).sort

def f(t)
  cnt = 0

  A.zip(F).each do |a, f|
    if a * f > t
      b = t / f
      cnt += a - b
    end
  end

  cnt <= K
end

if f(0)
  puts 0
  exit
end

ok = A.max * F.max
ng = 0

while (ok - ng).abs > 1
  mid = (ok + ng) / 2

  if f(mid)
    ok = mid
  else
    ng = mid
  end
end

puts ok
