let rec qsort compare ls =
  if ls = [] then []
  else
    let p, tl = (List.hd ls), (List.tl ls) in
    let left = List.filter (compare p) tl in
    let right = List.filter (fun x -> not @@ compare p x) tl in
    (qsort compare left) @ p::(qsort compare right)

let rec aux m cash drinks shops =
  if drinks >= m then cash
  else
    let a, b = List.hd shops in
    let shops = List.tl shops in
    if m - drinks >= b then aux m (cash + a * b) (drinks + b) shops
    else if m - drinks < b then aux m (cash + a * (m - drinks)) m shops
    else assert false 

let _ =
  let n, m = Scanf.scanf "%d %d\n" (fun n m -> (n, m)) in
  let pairs = ref [] in
  for i=1 to n do
    Scanf.scanf "%d %d\n" (fun a b -> pairs := (a, b)::!pairs)
  done;
  !pairs
  |> qsort (fun (a, _) (a', _) -> a >= a')
  |> aux m 0 0
  |> print_int