fun main() {
    val l = readLine()!!.split(' ').map { it.toLong() }
    val a = readLine()!!.split(' ').map { it.toInt() }
    val visited: MutableSet<Int> = mutableSetOf(0)
    val list: MutableList<Int> = mutableListOf(0)

    var x = 0
    var loopStartAt = 0
    for (i in 0 until l[1]) {
        x = a[x]-1
        if (visited.add(x)) {
            list.add(x)
        } else {
            loopStartAt = list.indexOf(x)
            break
        }
    }

    val res = if (l[1] < list.size) {
        list.last()
    } else {
        list.subList(loopStartAt, list.size)[((l[1]-loopStartAt)%(list.size-loopStartAt)).toInt()]
    }
    println(res+1)
}
