
let line = readLine()!.split(separator: " ").map({Int($0)!})
let (N, K) = (line[0], line[1])
let A = readLine()!.split(separator: " ").map({Int($0)! - 1})

var visit = Array(repeating: -1, count: N)

var cities: [Int] = []
var city = 0
while visit[city] < 0 {
    visit[city] = cities.count
    cities.append(city)
    city = A[city]
}

if K < cities.count {
    print(cities[K] + 1)
} else {
    let start = visit[city]
    print(cities[start + (K - start) % (cities.count - start)] + 1)
}
