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

A = [int(i) for i in input().split()]



R = [False]*(N+1)

D = []

p = 1

while True:

    if R[p]:

        break

    D.append(p)

    R[p] = True

    p = A[p-1]

m = D.index(p)

c = len(D)-m



if K <= m:

    print((D[K]))

else:

    print((D[m+(K-m) % c]))

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

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

e = [False] * (N+1)

idx = 1

move = []

while True:

  if e[idx]:

    break

  move.append(idx)

  e[idx] = True

  idx = A[idx-1]

m = move.index(idx)

c = len(move) - m



if K <= m:

    print((move[K]))

else:

    print((move[m+(K-m) % c]))

N, K = list(map(int, input().split()))
A = [int(i) for i in input().split()]
R = [False] * (N + 1)
D = []
p = 1
while True:
    if R[p]:
        break
    D.append(p)
    R[p] = True
    p = A[p - 1]
m = D.index(p)
c = len(D) - m
if K <= m:
    print((D[K]))
else:
    print((D[m + (K - m) % c]))

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
e = [False] * (N + 1)
idx = 1
move = []
while True:
    if e[idx]:
        break
    move.append(idx)
    e[idx] = True
    idx = A[idx - 1]
m = move.index(idx)
c = len(move) - m
if K <= m:
    print((move[K]))
else:
    print((move[m + (K - m) % c]))

-A = [int(i) for i in input().split()] -R = [False] * (N + 1) -D = [] -p = 1 +A = list(map(int, input().split())) +e = [False] * (N + 1) +idx = 1 +move = [] -    if R[p]: +    if e[idx]: -    D.append(p) -    R[p] = True -    p = A[p - 1] -m = D.index(p) -c = len(D) - m +    move.append(idx) +    e[idx] = True +    idx = A[idx - 1] +m = move.index(idx) +c = len(move) - m -    print((D[K])) +    print((move[K])) -    print((D[m + (K - m) % c])) +    print((move[m + (K - m) % c]))