object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, K = sc.nextInt
  val As = Seq.fill(N)(sc.nextLong)
  val Fs = Seq.fill(N)(sc.nextLong)
  val pq = collection.mutable.PriorityQueue[(Long, Long)]()(Ordering.by{t => t._1 * t._2})
  val as = As.sorted
  val fs = Fs.sorted(Ordering[Long].reverse)
  as.zip(fs).foreach(pq.enqueue(_))
  for(i <- 1 to K) {
    val t = pq.dequeue
    if(t._1 > 0)       pq.enqueue((t._1 - 1, t._2))
  }
  if(pq.isEmpty) println(0)
  else {
    val t = pq.dequeue
    println(t._1 * t._2)
  }
}