fun main() {
    val builder = StringBuilder()

    val (n, k) = readInputLine().split(" ").let { Pair(it[0].toInt(), it[1].toLong()) }

    val aArr = readInputLine().split(" ").map { it.toInt() - 1 }

    val visited = BooleanArray(n)

    val visitTrace = mutableListOf<Int>()

    var teleCnt = 0L
    var current = 0

    while (!visited[current]) {
        visited[current] = true
        visitTrace.add(current)

        current = aArr[current]
        teleCnt++
    }

    for ((i, a) in visitTrace.withIndex()) {
        if (i.toLong() == k) {
            builder.appendln(a + 1)
            break
        }
        if (a == current) {
            builder.appendln(visitTrace.drop(i)[((k - i.toLong()) % (teleCnt - i.toLong())).toInt()] + 1)
            break
        }
    }

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}
