# frozen_string_literal: true

n, @k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
f = gets.split.map(&:to_i).sort_by(&:-@)

@b = []
@c = []
0.upto(n - 1) do |i|
  @b.push [a[i], f[i]]
end

def ok(m)
  count = 0
  @b.each do |e|
    a = e[0]
    f = e[1]
    break if a * f <= m

    count += a - m / f
    return false if count > @k
  end
  return true
end

@b = @b.sort_by { |e| -e[0] * e[1] }
max = @b.map { |e| e[0] * e[1] }.max

ans = (0..max).bsearch { |e| ok(e) }

puts ans
