import sys

sys.setrecursionlimit(10**6)



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

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

L = [1]

S = {1}



def f(L, S):

    last = L[-1]-1

    if A[last] not in S:

        L.append(A[last])

        S |= {A[last]}

        return f(L, S)

    else:

        return L

P = f(L, S)

a = A[P[-1]-1]

j = P.index(a)

r = len(P)

l = r - j



if k+1 <= j:

    print((P[k]))

else:

    print((P[j+(k-j)%l]))
n, k = list(map(int, input().split()))

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

L = [1]

S = {1}



while A[L[-1]-1] not in S:

  last = L[-1]-1

  L.append(A[last])

  S |= {A[last]}



a = A[L[-1]-1]

j = L.index(a)

r = len(L)

l = r - j



if k+1 <= j:

    print((L[k]))

else:

    print((L[j+(k-j)%l]))

import sys

sys.setrecursionlimit(10**6)
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
L = [1]
S = {1}


def f(L, S):
    last = L[-1] - 1
    if A[last] not in S:
        L.append(A[last])
        S |= {A[last]}
        return f(L, S)
    else:
        return L


P = f(L, S)
a = A[P[-1] - 1]
j = P.index(a)
r = len(P)
l = r - j
if k + 1 <= j:
    print((P[k]))
else:
    print((P[j + (k - j) % l]))

n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
L = [1]
S = {1}
while A[L[-1] - 1] not in S:
    last = L[-1] - 1
    L.append(A[last])
    S |= {A[last]}
a = A[L[-1] - 1]
j = L.index(a)
r = len(L)
l = r - j
if k + 1 <= j:
    print((L[k]))
else:
    print((L[j + (k - j) % l]))

-import sys - -sys.setrecursionlimit(10**6) - - -def f(L, S): +while A[L[-1] - 1] not in S: -    if A[last] not in S: -        L.append(A[last]) -        S |= {A[last]} -        return f(L, S) -    else: -        return L - - -P = f(L, S) -a = A[P[-1] - 1] -j = P.index(a) -r = len(P) +    L.append(A[last]) +    S |= {A[last]} +a = A[L[-1] - 1] +j = L.index(a) +r = len(L) -    print((P[k])) +    print((L[k])) -    print((P[j + (k - j) % l])) +    print((L[j + (k - j) % l]))