import Data.List
import Control.Monad
import Data.Maybe
import Control.Arrow

main :: IO ()
main = do
  [n,k] <- rListM :: IO [Int]
  ls <- mapMaybe twl2tup <$> replicateM n rListM :: IO [(Int,Int)]
  let searched = find (\t -> snd t >= k) $ scanl1 (\(_,n') -> second (n' +)) (sort ls)
  let Just e = if isJust searched then searched else Just (0,0)
  print $ fst e

rListM :: Read a => IO [a]
rListM = fmap read . words <$> getLine

twl2tup :: [a] -> Maybe (a,a)
twl2tup [e1,e2] = Just (e1,e2)
twl2tup _ = Nothing
