fun main() {
    val inp = readLine()!!.split(" ")
    val N = inp[0].toInt()
    val K = inp[1].toLong()
    val A = readLine()!!.split(" ").map { it.toInt() - 1 }
    val visitedA = IntArray(N)

    var current = 0
    var shuuki = 0
    var currentTime = 0
    var flag = false
    for (i in 1..N) {
        current = A[current]

        if (i >= K) {
            flag = true
            break
        }

        if (visitedA[current] != 0) {
            shuuki = i - visitedA[current]
            currentTime = i
            break
        }

        visitedA[current] = i
    }

    if (flag) {
        println(current + 1)
    } else {
        val amari = (K - currentTime) % shuuki
        for (i in 0 until amari) {
            current = A[current]
        }
        println(current + 1)
    }
}
