@OptIn(ExperimentalStdlibApi::class)
fun main() {
    var (n, k) = readLine()!!.split(" ").map(String::toLong)
    val array = readLine()!!.split(" ").map { it.toInt() - 1 }.toIntArray()

    var set = mutableSetOf(0)
    var a = set.last()
    do {
        a = array[a]
    } while (set.add(a))

    val list = mutableListOf<Int>()

    var w = 0
    while (w != a) {
        list.add(w)
        w = array[w]
    }

    val cList = mutableListOf(a)
    w = array[w]
    while (w != a) {
        cList.add(w)
        w = array[w]
    }


    if (k < list.size) {
        println(list[k.toInt()] + 1)
    } else {
        println(cList[((k - list.size) % cList.size).toInt()] + 1)
    }
}



