import Data.Maybe
import qualified Data.ByteString.Char8 as BC8

main :: IO ()
main = do
  [n, k] <- (map read . words) <$> getLine :: IO [Int]
  print =<< solve k 0 0

solve k i a
  | k <= i = return a
  | otherwise = do
      [a', b'] <- map (fst . fromJust . BC8.readInt) . BC8.words <$> BC8.getLine
      solve k (i + b') a'
