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

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



now = 1



while K:

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



now = 1

route = []

dic = {}

cnt = 0

entry = []

loop = []



while True:

  cnt += 1

  now = A[now]

  route.append(now)

  if now in dic:

    entry = route[:dic[now]]

    loop = route[dic[now]:]

    break

  dic[now] = cnt



if K <= len(entry):

  print((entry[K - 1]))

else:

  K -= 1

  K -= len(entry)

  K %= len(loop)

  print((loop[K]))
N, K = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))
now = 1
while K:
    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()))
now = 1
route = []
dic = {}
cnt = 0
entry = []
loop = []
while True:
    cnt += 1
    now = A[now]
    route.append(now)
    if now in dic:
        entry = route[: dic[now]]
        loop = route[dic[now] :]
        break
    dic[now] = cnt
if K <= len(entry):
    print((entry[K - 1]))
else:
    K -= 1
    K -= len(entry)
    K %= len(loop)
    print((loop[K]))

-while K: -    if K & 1: -        now = A[now] -    A = [A[A[i]] for i in range(len(A))] -    K >>= 1 -print(now) +route = [] +dic = {} +cnt = 0 +entry = [] +loop = [] +while True: +    cnt += 1 +    now = A[now] +    route.append(now) +    if now in dic: +        entry = route[: dic[now]] +        loop = route[dic[now] :] +        break +    dic[now] = cnt +if K <= len(entry): +    print((entry[K - 1])) +else: +    K -= 1 +    K -= len(entry) +    K %= len(loop) +    print((loop[K]))