import Prelude hiding (abs)
import Control.Monad
import Control.Arrow ((&&&))
import Data.List (nub, sort, group, find)
import Data.Maybe (fromMaybe, fromJust)
import qualified Data.IntMap as M

type Counter = M.IntMap Int

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

-- |
--
-- >>> solve [(1,1),(2,2),(3,3)] 4
-- 3
solve :: [(Int,Int)] -> Int -> Int
solve abs k = fst y
  where
    c = foldl update M.empty abs
    y = head . dropWhile (\(_,b) -> b < k) $ scanl f (0,0) (sort $ M.assocs c)
    f (a1,b1) (a2,b2) = (a2, b1 + b2)

update :: Counter -> (Int,Int) -> Counter
update c (a,b) = M.insertWith (+) a b c

readLine2 :: String -> (Int,Int)
readLine2 = tuplify2 . map read . words
    where
      tuplify2 [] = (0, 0)
      tuplify2 [x] = (x, 0)
      tuplify2 (x:y:_) = (x, y)
