import Control.Monad main :: IO () main = do [n,k] <- map read . words <$> getLine replicateM_ (fromIntegral n-1) getLine print $ solve n k solve :: Int -> Int -> Int solve n k = if k > n then -1 else k - 1