(n, k), a, f = $<.map{|l| l.to_s.split.map(&:to_i) }
a.sort!
f.sort!
f.reverse!

m = []
n.times do |i|
   m << [a[i] * f[i], f[i]]
end

m.sort_by!{|(af, _)| -af }

ma = m[0][0]
ans = (0 .. ma).bsearch do |x|
  
  k_x = 0
  m.each do |(m_i, f_i)|
    break if m_i <= x
    k_x += ( m_i - x + f_i - 1 ) / f_i
  end
  
  k_x <= k
end

puts ans