type drink = {price: int; stock: int};;
let compare_drink d1 d2 = d1.price - d2.price;; 

let (+=) v add = v := !v + add;;

let input_drink_array n = Array.init n @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> {price = a; stock = b};;

let () = Scanf.scanf "%d %d" @@ fun n m -> 
  let drinks = input_drink_array n in (
    Array.fast_sort compare_drink drinks;
    let ans = ref 0 in
    let cnt = ref 0 in (
      for i = 0 to n - 1 do
        if drinks.(i).stock + !cnt < m then (
          ans += drinks.(i).price * drinks.(i).stock;
          cnt += drinks.(i).stock
        ) else if !cnt < m then (
          let rest = m - !cnt in (
            ans += drinks.(i).price * rest;
            cnt += m
          )
        )
      done;
      Printf.printf "%d\n" !ans
    )
  )
;;