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

asc_a = a.sort
desc_f = f.sort.reverse

def max_index(a, b)
  index = 0
  max = 0
  a.each_with_index do |v, i|
    value = a[i] * b[i]
    if max < value
      max = value
      index = i
    end
  end
  index
end

i = 1
while i <= k && !asc_a.none?(&:positive?)
  max_index = max_index(asc_a, desc_f)
  asc_a[max_index] -= 1
  i += 1
end

puts asc_a.each_with_index.map { |item, index| item * desc_f[index] }.max