import Data.List
f s=(\[a,b]->(a,b)).read.words s
g k (x:[])=fst x 
g k (x:y:xs)=if snd x+snd y < k then g (k-snd x) (y:xs) else fst y
main=do
 [n,k]<-map read.words<$>getLine
 ab<-mapM_ f<$>getLine
 let abl=sortBy (\x y->if fst x<=fst y then LT else GT) ab
 print$g k abl