import Control.Monad
import Data.List
import Data.Function
import Data.Maybe
import qualified Data.ByteString.Char8 as BC8

main :: IO ()
main = do
  [n, k] <- (map read . words) <$> getLine :: IO [Int]
  rows <- replicateM n $ map (fst . fromJust . BC8.readInt) . BC8.words <$> BC8.getLine :: IO [[Int]]
  let sorted = sortBy (compare `on` head) rows
  print =<< solve k 0 0 sorted

solve k i a' rows
  | k <= i = return a'
  | otherwise = let [a, b]:rows' = rows in solve k (i + b) a rows'
