{-# LANGUAGE BangPatterns #-}
import Control.Arrow (second)
import Control.Monad
import Control.Monad.Fix
import Data.List (foldl')
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import System.IO.Unsafe
import Debug.Trace

solve :: Int -> Int -> VU.Vector (Int,Int) -> Integer
solve !n !k !wds = nearest $ let i = findInternal 1 in search i (2*i) where
  calc :: Integer -> Integer
  calc !t = VU.foldl' (\(!acc) (!w,!d) -> (acc +) $ if t >= fromIntegral w then (t - fromIntegral w) `div` fromIntegral d + 1 else 0) 0 wds

  nearest :: Integer -> Integer
  nearest !t = VU.foldl' (\(!acc) (!w,!d) -> max acc $ fromIntegral w + ((t - fromIntegral w) `div` fromIntegral d) * fromIntegral d) 0 wds

  findInternal !t = last $ takeWhile (\t -> calc t <= fromIntegral k) $ map (\k -> (2^k :: Integer)) [0..]

  search !a !b =
    let c = (a + b) `div` 2
        u = calc c
    in
      if u == fromIntegral k then c
      else if u < fromIntegral k then search (c+1) b
      else search a (c-1)

main = do
  let readInt = fmap (second B.tail) . B.readInt

  nk <- VU.unfoldrN 2 readInt <$> B.getLine
  wds <- VU.replicateM (nk VU.! 0) ((\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine)
  print $ solve (nk VU.! 0) (nk VU.! 1) wds
