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

list = a.zip(f).map{ |ai,fj| ai*fj }

min, max = 0, list.max

while min < max
  mean = (min+max)/2
  sum = 0
  n.times do |i|
    sum += (list[i]-mean+(f[i]-1))/f[i] if list[i] > mean
  end
  if sum <= k
    max = mean
  else
    min = mean + 1
  end
end

puts(max)