require "matrix"

$n, $k = gets.split.map(&:to_i)
$a = gets.split.map(&:to_i)
$f = gets.split.map(&:to_i)
$a.sort!
$f.sort!.reverse!

def check(x) # x以下のコストにできるか
  $n.times.map{|i| $a[i] * $f[i] > x ? $a[i] - x / $f[i] : 0}.inject(:+)<= $k
  # ($a.zip($f).map { |ai, fi| ai * fi > x ? ai - x / fi : 0 }.inject(:+)) <= $k
end

ok = 10 ** 18
ng = -1
while (ok - ng).abs > 1
  mid = (ok + ng) / 2
  if check(mid)
    ok = mid
  else
    ng = mid
  end
end
p ok
