n, k = gets.to_s.split.map{|t| t.to_i }
a    = gets.to_s.split.map{|t| t.to_i }.sort
f    = gets.to_s.split.map{|t| t.to_i }.sort.reverse

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

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

ans = (0 .. m[0][0]).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