{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative
import           Debug.Trace

readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons

main = do
  [n,k] <- map read . words <$> getLine :: IO [Int]
  as <- getIntVector
  let as' = (VU.fromList [0]) VU.++ as

  dp <- VUM.replicate (n+1) (0 :: Int)
  -- VUM.write dp 1 1
  (referenceTown,period,lengthToRefTown) <- checkLoop as' dp
  let k' = (k-lengthToRefTown) `mod` period

  print $ ans referenceTown k' as'

-- test = do
--   let n = 6
--       k = 727202214173249351
--       as' = VU.fromList $ 0:[6,5,2,5,3,2]
--   dp <- VUM.replicate (n+1) (0 :: Int)
--   -- VUM.write dp 1 1
--   (referenceTown,period,lengthToRefTown) <- checkLoop as' dp
--   let k' = (k-lengthToRefTown) `mod` period


--   print $ ans referenceTown k' as'

checkLoop as dp = loop 1 0
  where
    loop now n = do
      let next = as VU.! now
      nextTownHowManyTimesVisit <- VUM.read dp next
      if nextTownHowManyTimesVisit == 0 && next /= 1
        then do
        VUM.write dp now n
        loop next (n+1)
        else do
        return (next, n+1-nextTownHowManyTimesVisit,nextTownHowManyTimesVisit)

ans start step as = loop start step
  where
    loop now 0 = now
    loop now n = loop next (n-1)
      where
        next = as VU.! now
