n, k = list(map(int, input().split()))

A = list([int(x)-1 for x in input().split()])

bit = k.bit_length()

table = [[0]*n for _ in range(bit)]

table[0] = A



for i in range(1, bit):

    for j in range(n):

        table[i][j] = table[i-1][table[i-1][j]]



ans = 0

for i in reversed(list(range(bit))):

    if (1 << i) <= k:

        k -= 1 << i

        ans = table[i][ans]

print((ans+1))
n, k = list(map(int, input().split()))

A = list([int(x)-1 for x in input().split()])



history = [-1]*n

cur = 0

for i in range(n):

    if history[cur] != -1:

        init_cnt = history[cur]

        loop_cnt = i - history[cur]

        break

    history[cur] = i

    cur = A[cur]



loop = k if k <= init_cnt else init_cnt+((k-init_cnt) % loop_cnt)

print((history.index(loop)+1))
n, k = list(map(int, input().split()))
A = list([int(x) - 1 for x in input().split()])
bit = k.bit_length()
table = [[0] * n for _ in range(bit)]
table[0] = A
for i in range(1, bit):
    for j in range(n):
        table[i][j] = table[i - 1][table[i - 1][j]]
ans = 0
for i in reversed(list(range(bit))):
    if (1 << i) <= k:
        k -= 1 << i
        ans = table[i][ans]
print((ans + 1))

n, k = list(map(int, input().split()))
A = list([int(x) - 1 for x in input().split()])
history = [-1] * n
cur = 0
for i in range(n):
    if history[cur] != -1:
        init_cnt = history[cur]
        loop_cnt = i - history[cur]
        break
    history[cur] = i
    cur = A[cur]
loop = k if k <= init_cnt else init_cnt + ((k - init_cnt) % loop_cnt)
print((history.index(loop) + 1))

-bit = k.bit_length() -table = [[0] * n for _ in range(bit)] -table[0] = A -for i in range(1, bit): -    for j in range(n): -        table[i][j] = table[i - 1][table[i - 1][j]] -ans = 0 -for i in reversed(list(range(bit))): -    if (1 << i) <= k: -        k -= 1 << i -        ans = table[i][ans] -print((ans + 1)) +history = [-1] * n +cur = 0 +for i in range(n): +    if history[cur] != -1: +        init_cnt = history[cur] +        loop_cnt = i - history[cur] +        break +    history[cur] = i +    cur = A[cur] +loop = k if k <= init_cnt else init_cnt + ((k - init_cnt) % loop_cnt) +print((history.index(loop) + 1))