import Control.Applicative
import Data.List
import qualified Data.Set as Set
import qualified Data.IntMap as IMap

main = do
    [n,k] <- map read . words <$> getLine  :: IO [Int]
    list <- sequence (replicate n ((\[x,y]->(x,y)) . map read . words <$> getLine)) :: IO [(Int,Int)]
    print $ solve k list

solve :: Int -> [(Int,Int)] -> Int
solve k list = fd k dic
    where dic = make list


fd k dic = if b >= k then a else (fd (k-b) dic)
    where ((a,b),dic_) = IMap.deleteFindMin dic

make :: [(Int,Int)] -> IMap.IntMap Int
make list = foldl (\acc (a,b)->append acc a (a,b)) IMap.empty list

append :: IMap.IntMap Int -> Int -> (Int,Int) -> IMap.IntMap Int
append dic key (a,b) = case mb of Nothing -> IMap.insert key b dic
                                  Just x  -> IMap.update (\y -> Just (x+y)) key dic
    where mb = IMap.lookup key dic


test = IMap.fromList [(1,3),(2,4),(3,1)]
