import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
main = do
  [n,k] <- map read . words <$> getLine :: IO [Int]
  xs <- map (\[a,b] -> (a,b)) . map (map read . words) . lines <$> getContents :: IO [(Int,Int)]
  let v = vec xs n
  print ""

vec :: [(Int,Int)] -> Int -> VU.Vector Int
vec xs n = 
  VU.create $ do
    vec <- VUM.replicate (n+1) (0::Int)
    forM_ xs $ \(a,b) -> do
      r <- VUM.read vec a
      VUM.write vec a (b+r)
    return vec

find :: VU.Vector Int -> Int -> Int -> Int
find vec n k
  | vec VU.! n >= k = n
  | otherwise = find vec (n+1)