fun main() {
    val l = readLine()!!.split(" ")
    val n = l[0].toInt()
    val k = l[1].toLong()
    val array = readLine()!!.split(" ").map { it.toInt() - 1}
    val flags = Array(n){-1L}
    var current = 0
    var mod = 0L
    var remain = 0L
    for(i in 0..k-1){
        if(flags[current]!=-1L){
            mod = i-flags[current]
            remain = k-i
            break
        }
        flags[current] = i
        current = array[current]
    }
    if(mod==0L){
        println(current+1)
        return
    }
    val x = remain%mod
    if(x==0L) {
        println(current+1)
    }else{
        for(i in 0..x-1) {
            current = array[current]
        }
        println(current+1)
    }
}