
input = gets.chomp.split(" ").map(&:to_i)
N = input[0]
K = input[1]

people = gets.chomp.split(" ").map(&:to_i).sort
foods = gets.chomp.split(" ").map(&:to_i).sort.reverse
products = []
people.each_with_index do |e,i|
  products << e*foods[i]
end

K.times do
  maximum = products.max
  break if maximum == 0
  maxplace = products.index(maximum)
  people[maxplace] -= 1
  products[maxplace] -= foods[maxplace]
end

puts products.max