open System

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

let a =
    Console.ReadLine().Split(' ') |> Array.map (fun x -> int (x) - 1)

let ans =
    let loop =
        let mutable set = Set<int> []
        let mutable found = false
        let mutable tmp = 0
        [ while not found do
            yield tmp
            if set.Contains tmp then
                found <- true
            else
                set <- set.Add tmp
                tmp <- a.[tmp] ]

    let loopOrigin = loop |> List.findIndex (fun t -> t = (loop |> List.last))
    let freq = (loop |> List.length) - 1 - loopOrigin

    if k < int64 (loopOrigin) then
        loop.[int (k)] + 1
    else
        let idx =
            let lo = int64 (loopOrigin)
            let freq = int64 (freq)
            loopOrigin + int ((k - lo) % freq)
        loop.[idx] + 1

ans |> Console.WriteLine
