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

a.sort!
f.sort!.reverse!

array = a.zip(f)
array.sort_by!{|x,y| -x*y}

def ok?(array, threashold, k)
  array.each do |x, y|
    if x * y > threashold
      k -= x - threashold / y
    end
    if k < 0
      return false
    end
  end
  return true
end

minans = 0
maxans = 10**6
while true
  threashold = (minans + maxans) / 2
  if ok?(array, threashold, k)
    maxans = threashold
  else
    minans = threashold
  end

  # p [minans, maxans]
  if maxans - minans <= 1
    if ok?(array, minans, k)
      puts minans
      break
    else
      puts maxans
      break
    end
  end
end