
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
// O(n^2)
while true {
    let hoge = As[current - 1]
    map[current - 1].append(count)
    if map[current - 1].count == 2 { break }
    current = hoge
    count += 1
}

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

    var result = index + 1
    // O(n)
    for _ in 0..<offset {
        result = As[result - 1]
    }
    print(result)
} else {
    print(map.firstIndex { $0.contains(K) }! + 1)
}

// MARK: -----------------------------------------------------------------------


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

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating get {
            if let note = dictionary[argument] {
                return note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                return result
            }
        }
    }
}
