n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
f = gets.split.map(&:to_i)

a.sort!

f.sort!
f.reverse!

l = -1
r = 10**12

while (r-l != 1) do
    mid = (r+l) / 2
    cnt = 0
    for i in 0...n
        x = a[i] - mid / f[i]
        cnt += x if x > 0
    end

    if cnt <= k
        r = mid
    else
        l = mid
    end
end

puts r
