n,k = gets.split.map &:to_i
as = gets.split.map &:to_i
fs = gets.split.map &:to_i

as = as.sort
fs = fs.sort.reverse

as_n = []

as.each{ |x|
	if x > k then
		as_n << (x - k)
		k = 0
	else
		as_n << 0
		k = k - x
	end
}

max = 0

as_n.each_with_index{ |x, i|
	max += x * fs[i]
}

puts max
