(* O(n * log(n)) *)
let solve n m ab_s =
  let sorted_ab_s = List.sort (fun (a1, _) (a2, _) -> compare a1 a2) ab_s in
  let rec find money rest_m = function
  | [] -> money
  | (a, b) :: rest ->
    if rest_m <= 0 then
      money
    else
      find (money + a * min b rest_m) (rest_m - b) rest
  in
    find 0 m sorted_ab_s

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string
(* O(n) *)
let rec fold_btw f a i n = if i >= n then a else fold_btw f (f a i) (i + 1) n
let fold_int f a n = fold_btw f a 0 n

let _ =
  match read_ints () with
  | [n; m] ->
    fold_int (fun acc _ ->
      match read_ints () with
      | [a; b] -> (a, b) :: acc
      | _ -> acc) [] n |> List.rev |> solve n m |> string_of_int |> print_endline
  | _ -> ()