{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}

import qualified Data.ByteString.Char8 as B
import Data.Attoparsec.ByteString.Char8
import Data.List (sort)

type Input  = (Int, Int, [(Int, Int)])
type Output = Int

input :: Parser Input
input = do
  (_N, _M) <- decimalPair
  _ABs <- count _N decimalPair
  return (_N, _M, _ABs)

decimalPair :: Parser (Int, Int)
decimalPair = (,)
  <$> decimal <* char ' '
  <*> decimal <* endOfLine

main :: IO ()
main = B.interact
  $ B.pack . show . either (error "parse err") solve . parseOnly input

solve :: Input -> Output
solve (_N, _M, _ABs) = go 0 _M $ sort _ABs
  where
    go !n !m ((a, b) : abs)
      | m <= b    = n + a * m
      | otherwise = go (n + a * b) (m - b) abs