object Main extends App {
  import scala.io.StdIn._
  val Array(n, m) = readLine().split(" ").map(_.toInt)
  val a = new Array[Long](n)
  val map = scala.collection.mutable.HashMap[Long,Long]()
  for(i <- (0 until(n))) {
    val Array(aa, bb) = readLine().split(" ").map(_.toInt)
    a(i) = aa
    map(aa) = if(map.contains(aa)) map(aa) + bb else bb
  }
  val aA = a.sorted
  var ans = 0L
  var ind = 0
  for(i <- (1 to m)){
    if(map(aA(ind)) == 0){
      ind += 1
    }
    ans += aA(ind)
    map(aA(ind)) -= 1
  }
  println(ans)
}