import sys

input = sys.stdin.readline

from collections import *



N, K = list(map(int, input().split()))

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

log_size = 100

dp = [[0]*N for _ in range(log_size)]



for i in range(N):

    dp[0][i] = A[i]-1

    

for i in range(1, log_size):

    for j in range(N):

        dp[i][j] = dp[i-1][dp[i-1][j]]



c = 0

cur = 0

    

while K>0:

    if K&1:

        cur = dp[c][cur]

        

    c += 1

    K >>= 1



print((cur+1))
import sys

input = sys.stdin.readline



N, K = list(map(int, input().split()))

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

l = [0]

s = {0}



for i in range(K):

    nex = A[l[-1]]-1

    

    if nex in s:

        for i in range(len(l)):

            if l[i]==nex:

                mark = i

                break

        

        t = len(l)-mark

        print((l[mark+(K-mark)%t]+1))

        exit()

    

    l.append(nex)

    s.add(nex)



print((nex+1))
import sys

input = sys.stdin.readline
from collections import *

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
log_size = 100
dp = [[0] * N for _ in range(log_size)]
for i in range(N):
    dp[0][i] = A[i] - 1
for i in range(1, log_size):
    for j in range(N):
        dp[i][j] = dp[i - 1][dp[i - 1][j]]
c = 0
cur = 0
while K > 0:
    if K & 1:
        cur = dp[c][cur]
    c += 1
    K >>= 1
print((cur + 1))

import sys

input = sys.stdin.readline
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
l = [0]
s = {0}
for i in range(K):
    nex = A[l[-1]] - 1
    if nex in s:
        for i in range(len(l)):
            if l[i] == nex:
                mark = i
                break
        t = len(l) - mark
        print((l[mark + (K - mark) % t] + 1))
        exit()
    l.append(nex)
    s.add(nex)
print((nex + 1))

-from collections import * - -log_size = 100 -dp = [[0] * N for _ in range(log_size)] -for i in range(N): -    dp[0][i] = A[i] - 1 -for i in range(1, log_size): -    for j in range(N): -        dp[i][j] = dp[i - 1][dp[i - 1][j]] -c = 0 -cur = 0 -while K > 0: -    if K & 1: -        cur = dp[c][cur] -    c += 1 -    K >>= 1 -print((cur + 1)) +l = [0] +s = {0} +for i in range(K): +    nex = A[l[-1]] - 1 +    if nex in s: +        for i in range(len(l)): +            if l[i] == nex: +                mark = i +                break +        t = len(l) - mark +        print((l[mark + (K - mark) % t] + 1)) +        exit() +    l.append(nex) +    s.add(nex) +print((nex + 1))