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

(0..N-1).each do |i|
  if people[i] >= K
    people[i] -= K
    K = 0
  else
    K -= people[i]
    people[i] = 0
  end
end

sum = 0
(0..N-1).each do |e|
  sum += people[e]*foods[e]
end

puts sum
