module Main where
-- import qualified Data.Vector                   as V
-- import qualified Data.Vector.Mutable           as VM
-- import qualified Data.Vector.Unboxed           as U
-- import qualified Data.Foldable                 as F
import Data.Ord
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List

teleport::[Int]->Int->Int->Int->Int->Int
teleport an n 1 _ _= an !! (n-1)
teleport an n k w l
        | an !! (n-1) == w = if (k-1) `mod` l == 0 then an !! (n-1) else teleport an (an !! (n-1)) ( (k-1) `mod` l ) w l
        | otherwise = teleport an (an !! (n-1)) (k-1) w l

loopRoute::[Int]->Int->[Int]->(Int,Int)
loopRoute an n ln
                | (an !! (n-1)) `elem` ln = ( an !! (n-1) , length ln - fromJust (elemIndex (an !! (n-1)) ln ) )
                | otherwise = loopRoute an (an !! (n-1)) ( ln ++ [an !! (n-1)] )

main :: IO ()
main = do
        [n,k] <- map (fst.fromJust.BS.readInt).BS.words <$> BS.getLine
        as <- map (fst.fromJust.BS.readInt).BS.words <$> BS.getLine
        -- let [n,k] = [6, 727202214173249351]
        -- let as = [6, 5, 2, 5, 3, 2]
        let (w,l) = loopRoute as 1 []
        -- print $ (w,l)
        print $ teleport as 1 k w l




-------------------------------------------------------------------
-- Util
------------------------------------------------------------------

-- IO
-- n <- fst . fromJust <$> ( BS.readInt <$> BS.getLine ) :: IO Int
-- [n,q] <- map (fst.fromJust.BS.readInt).BS.words <$> BS.getLine
-- as <- replicateM n $ fst . fromJust <$> ( BS.readInt <$> BS.getLine ) :: IO [Int]
-- ass <- replicateM n $ map (fst.fromJust.BS.readInt).BS.words <$> BS.getLine :: IO[[Int]]
-- ass <- V.replicateM n $ do
        --U.unfoldrN (m+1) (runParser int) <$> C.getLine
-- css <- VU.concat <$> (replicateM h $ VU.unfoldrN w BS.uncons <$> BS.getLine)

-- powerset
-- powerset :: [a] -> [[a]]
-- powerset = filterM (const [True, False])

-- Descending sort 
-- sortBy (comparing Down)
