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

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

c=1

while K:

  if K&1:

    c=A[c]

  A=[A[A[i]] for i in range(N+1)]

  K>>=1

print(c)
import sys

readline = sys.stdin.readline



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

A = [0] + list(map(int,readline().split()))



now = 1

while K > 0:

  if K & 1:

    now = A[now]

  A = [A[A[i]] for i in range(len(A))]

  K >>= 1



print(now)
N, K = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))
c = 1
while K:
    if K & 1:
        c = A[c]
    A = [A[A[i]] for i in range(N + 1)]
    K >>= 1
print(c)

import sys

readline = sys.stdin.readline
N, K = list(map(int, readline().split()))
A = [0] + list(map(int, readline().split()))
now = 1
while K > 0:
    if K & 1:
        now = A[now]
    A = [A[A[i]] for i in range(len(A))]
    K >>= 1
print(now)

-N, K = list(map(int, input().split())) -A = [0] + list(map(int, input().split())) -c = 1 -while K: +import sys + +readline = sys.stdin.readline +N, K = list(map(int, readline().split())) +A = [0] + list(map(int, readline().split())) +now = 1 +while K > 0: -        c = A[c] -    A = [A[A[i]] for i in range(N + 1)] +        now = A[now] +    A = [A[A[i]] for i in range(len(A))] -print(c) +print(now)