import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as BS
main=do
 [n,k]<-map read.words<$>getLine
 ab<-replicateM n (map(read.BS.unpack).BS.words<$>BS.getLine)
 print(f (sort ab) k)
  where f ([a,b]:ab) k = if b<k then (f ab (k-b)) else a