import Data.List
main = do
 [n,k] <- map read . words <$> getLine
 asbs<-replicateM n (map read . words <$> getLine)
 let asbsx = zip asbs [0..]
 let as = map fst (filter (even . snd) asbsx)
 let bs = map fst (filter (odd . snd) asbsx)
 print ((sort $ f as bs) !! (k-1))

f [] [] = []
f (x:xs) (y:ys) = (replicate y x) ++ (f xs ys)