let (N, K) = readLine()!.split(separator: " ").map { Int($0)! }.mapToTuple()
let As = readLine()!.split(separator: " ").map { Int($0)! }

var map = Array(repeating: [Int](), count: N)
var current = 1
var count = 0
while map.allSatisfy({ $0.count < 2}) {
    let hoge = As[current - 1]
    map[current - 1].append(count)
    current = hoge
    count += 1
}

let index = map.firstIndex(where: { $0.count == 2 })!
let (first, next) = map[index].mapToTuple()
let offset = (K - first) % (next - first)

var result = index + 1
for _ in 0..<offset {
    result = As[result - 1]
}
print(result)

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
}
