fun main() {
    val (n, k) = run {
        val (n, k) = readLine()!!.split(' ').map { it.toLong() }
        n.toInt() to k
    }
    val a = readLine()!!.split(' ').map { it.toInt() }

    val (s, l, c) = run {
        val r = mutableListOf<Int>()
        val visited = IntArray(n + 1) { -1 }

        var v = 1
        while (visited[v] == -1) {
            visited[v] = r.size
            r.add(v)
            v = a[v - 1]
        }

        val l = visited[v]
        val c = r.size - visited[v]
        Triple(r, l, c)
    }

    val i = if (k < l) {
        k.toInt()
    } else {
        ((k - l) % c).toInt() + l
    }

    println(s[i])
}
