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)
import sys

readline = sys.stdin.readline



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

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



pos = 1



while K:

  if K & 1:

    pos = A[pos]

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

  K >>= 1

  

print(pos)
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)

import sys

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

-now = 1 -while K > 0: +pos = 1 +while K: -        now = A[now] -    A = [A[A[i]] for i in range(len(A))] +        pos = A[pos] +    A = [A[A[i]] for i in range(N + 1)] -print(now) +print(pos)