import Control.Monad
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as B

main = do
    [n,k] <- map read . words <$> getLine :: IO [Int]
    ns <- sort <$> replicateM n ((\[a,b]->(a,b)) . 
            map (fst . fromJust . B.readInt) . B.words <$> B.getLine) :: IO [(Int,Int)]
    print $ f k ns

f i ((n,m):ns)
    | i-m <= 0  = n
    | otherwise = f (i-m) ns
    

