n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
f = gets.split.map(&:to_i).sort_by{|e| -e}

a.map!.with_index{|e, i| [e * f[i], f[i]]}
a.sort_by!{|e| -e[0]}

l = 0
r = a[0][0]

while l != r
    m = (l + r) / 2
    s = 0

    a.each do |x, y|
        break if s > k || x <= m
        s += (x - m).fdiv(y).ceil
    end

    s > k ? l = m + 1 : r = m
end

puts l