open System

let n, k =
    let l = Console.ReadLine().Split(' ') |> Array.map Int64.Parse
    l.[0], l.[1]

let a =
    Console.ReadLine().Split(' ')
    |> Array.map Int64.Parse
    |> Array.toList
    |> List.map (fun x -> x - 1L)

let ans =
    let mutable map = Map<Int64, Int64> []
    let mutable rev = Map<Int64, Int64> []

    let loopOrigin, freq =
        let mutable cur = 0L
        let mutable i = 0L
        let mutable freq = 0L
        let mutable loopOrigin = 0L
        let mutable found = false
        while not found do
            match map.TryFind cur with
            | None ->
                map <- map |> Map.add cur i
                rev <- rev |> Map.add i cur
                cur <- a.[int(cur)]
                i <- i + 1L
            | _ ->
                found <- true
                loopOrigin <- map.[cur]
                freq <- i - loopOrigin
        loopOrigin, freq

    if k < loopOrigin
    then rev.[k] + 1L
    else rev.[loopOrigin + (k - loopOrigin) % freq] + 1L

ans |> Console.WriteLine