import java.util.*

fun main(args : Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toLong() }
    val aa = readLine()!!.split(" ").map { it.toInt()-1 }

    val dfs = ArrayDeque<Int>()
    dfs.addLast(0)

    var seen = BooleanArray(n.toInt()) {false}
    seen[0] = true

    val route = mutableListOf<Int>()
    var rep = 0

    while (dfs.isNotEmpty()) {
        val idx = dfs.removeFirst()
        val a = aa[idx]

        if (seen[a]) {
            if (a != 0) {
                rep = route.size - route.indexOf(a)
            } else {
                route.add(a)
                rep = route.size
            }
            break
        }

        seen[a] = true
        route.add(a)
        dfs.addLast(a)
    }

    if (k <= route.size) {
        println(route[k.toInt()-1]+1)
    } else {
        val pre = route.size-rep
        var idx = ((k - pre) % rep).toInt() - 1
        if (idx < 0) idx = rep-1
        println(route[pre+idx]+1)
    }
}