str = gets.split
N,K = str[0].to_i, str[1].to_i
a = Array.new(N)
f = Array.new(N)
v = 0
str = gets.split
for i in 0...N do
    a[i] = str[i].to_i
    v += a[i]
end
a.sort!
str = gets.split
for i in 0...N do
    f[i] = str[i].to_i
end
f.sort!.reverse!

t = v - K
if t <= 0
    puts 0
    exit
end

l = 1
r = 10**12
while l != r
    c = (l+r)/2
    s = 0
    for i in 0...N do
        s += c > a[i] * f[i] ? a[i] : c / f[i] 
    end
    if s >= t
        r = c
    else
        l = c+1
    end
end
puts l