def main():

    import sys

    input = sys.stdin.readline

    sys.setrecursionlimit(10**7)

    from collections import Counter, deque

    from itertools import combinations, permutations, accumulate, groupby, product

    from bisect import bisect_left,bisect_right

    from heapq import heapify, heappop, heappush

    import math

    #from math import gcd



    #inf = 10**17

    #mod = 10**9 + 7



    n,k = list(map(int, input().split()))

    a = list(map(int, input().split()))

    db = [a]

    cnt = k.bit_length()

    for c in range(1, cnt):

        temp = [0]*n

        for i in range(n):

            temp[i] = db[c-1][db[c-1][i]-1]

        db.append(temp)



    res = 1

    for i in range(cnt):

        if (k>>i) & 1:

            res = db[i][res-1]

    print(res)



if __name__ == '__main__':

    main()
def main():

    import sys

    input = sys.stdin.readline

    sys.setrecursionlimit(10**7)

    from collections import Counter, deque

    from itertools import combinations, permutations, accumulate, groupby, product

    from bisect import bisect_left,bisect_right

    from heapq import heapify, heappop, heappush

    import math

    #from math import gcd



    #inf = 10**17

    #mod = 10**9 + 7



    n,k = list(map(int, input().split()))

    a = [0] + list(map(int, input().split()))

    # visited[i]:町iにvisited[i]回目の遷移で到達

    visited = [0]*(n+1)

    step = 0

    i = 1



    while k:

        i = a[i]

        step += 1

        k -= 1

        if visited[i] != 0:

            k = k % (step - visited[i])

            for _ in range(k):

                i = a[i]

            print(i)

            break

        visited[i] = step

    else:

        print(i)



if __name__ == '__main__':

    main()
def main():
    import sys

    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left, bisect_right
    from heapq import heapify, heappop, heappush
    import math

    # from math import gcd
    # inf = 10**17
    # mod = 10**9 + 7
    n, k = list(map(int, input().split()))
    a = list(map(int, input().split()))
    db = [a]
    cnt = k.bit_length()
    for c in range(1, cnt):
        temp = [0] * n
        for i in range(n):
            temp[i] = db[c - 1][db[c - 1][i] - 1]
        db.append(temp)
    res = 1
    for i in range(cnt):
        if (k >> i) & 1:
            res = db[i][res - 1]
    print(res)


if __name__ == "__main__":
    main()

def main():
    import sys

    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left, bisect_right
    from heapq import heapify, heappop, heappush
    import math

    # from math import gcd
    # inf = 10**17
    # mod = 10**9 + 7
    n, k = list(map(int, input().split()))
    a = [0] + list(map(int, input().split()))
    # visited[i]:町iにvisited[i]回目の遷移で到達
    visited = [0] * (n + 1)
    step = 0
    i = 1
    while k:
        i = a[i]
        step += 1
        k -= 1
        if visited[i] != 0:
            k = k % (step - visited[i])
            for _ in range(k):
                i = a[i]
            print(i)
            break
        visited[i] = step
    else:
        print(i)


if __name__ == "__main__":
    main()

-    a = list(map(int, input().split())) -    db = [a] -    cnt = k.bit_length() -    for c in range(1, cnt): -        temp = [0] * n -        for i in range(n): -            temp[i] = db[c - 1][db[c - 1][i] - 1] -        db.append(temp) -    res = 1 -    for i in range(cnt): -        if (k >> i) & 1: -            res = db[i][res - 1] -    print(res) +    a = [0] + list(map(int, input().split())) +    # visited[i]:町iにvisited[i]回目の遷移で到達 +    visited = [0] * (n + 1) +    step = 0 +    i = 1 +    while k: +        i = a[i] +        step += 1 +        k -= 1 +        if visited[i] != 0: +            k = k % (step - visited[i]) +            for _ in range(k): +                i = a[i] +            print(i) +            break +        visited[i] = step +    else: +        print(i)