from collections import deque



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

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

T = set([0])  # 0-indexed



c = 0  # 0-indexed

for i in range(N + 1):

    c = A[c] - 1

    # print('c', c)

    if c not in T:

        T.add(c)

    else:

        break

C = deque([c])

T = set([c])  # 0-indexed

for i in range(N + 1):

    c = A[c] - 1

    # print('c', c)

    if c not in T:

        T.add(c)

        C.append(c)

    else:

        break

c2 = 0  # 0-indexed

S = deque([0])

for i in range(N + 1):

    c2 = A[c2] - 1

    if c2 == c:

        break

    else:

        S.append(c2)

# print('C', C)

# print('S', S)

# print('len(C), len(S)', len(C), len(S))



if C[0] == 0:

    mod = K % len(C)

    ans = C[mod]

else:

    if len(S) > K:

        ans = S[K]

    else:

        mod = (K - len(S)) % len(C)

        ans = C[mod]

print((ans + 1))

import sys

input = sys.stdin.buffer.readline

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

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



I = [-1] * (N + 1)

S = []

idx = 1

while I[idx] == -1:

    S.append(idx)

    I[idx] = len(S)

    idx = A[idx]

# print(f'{S=}, {idx=}, {I[idx]=}')



start_idx = I[idx] - 1

num_circles = len(S) - start_idx

# print(f'{start_idx=}, {num_circles=}')



if K < len(S) - 1:

    ans = S[K]

else:

    K -= start_idx

    div, mod = divmod(K, num_circles)

    ans = S[start_idx + mod]

print(ans)

from collections import deque

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
T = set([0])  # 0-indexed
c = 0  # 0-indexed
for i in range(N + 1):
    c = A[c] - 1
    # print('c', c)
    if c not in T:
        T.add(c)
    else:
        break
C = deque([c])
T = set([c])  # 0-indexed
for i in range(N + 1):
    c = A[c] - 1
    # print('c', c)
    if c not in T:
        T.add(c)
        C.append(c)
    else:
        break
c2 = 0  # 0-indexed
S = deque([0])
for i in range(N + 1):
    c2 = A[c2] - 1
    if c2 == c:
        break
    else:
        S.append(c2)
# print('C', C)
# print('S', S)
# print('len(C), len(S)', len(C), len(S))
if C[0] == 0:
    mod = K % len(C)
    ans = C[mod]
else:
    if len(S) > K:
        ans = S[K]
    else:
        mod = (K - len(S)) % len(C)
        ans = C[mod]
print((ans + 1))

import sys

input = sys.stdin.buffer.readline
N, K = list(map(int, input().split()))
A = [-1] + list(map(int, input().split()))
I = [-1] * (N + 1)
S = []
idx = 1
while I[idx] == -1:
    S.append(idx)
    I[idx] = len(S)
    idx = A[idx]
# print(f'{S=}, {idx=}, {I[idx]=}')
start_idx = I[idx] - 1
num_circles = len(S) - start_idx
# print(f'{start_idx=}, {num_circles=}')
if K < len(S) - 1:
    ans = S[K]
else:
    K -= start_idx
    div, mod = divmod(K, num_circles)
    ans = S[start_idx + mod]
print(ans)

-from collections import deque +import sys +input = sys.stdin.buffer.readline -A = list(map(int, input().split())) -T = set([0])  # 0-indexed -c = 0  # 0-indexed -for i in range(N + 1): -    c = A[c] - 1 -    # print('c', c) -    if c not in T: -        T.add(c) -    else: -        break -C = deque([c]) -T = set([c])  # 0-indexed -for i in range(N + 1): -    c = A[c] - 1 -    # print('c', c) -    if c not in T: -        T.add(c) -        C.append(c) -    else: -        break -c2 = 0  # 0-indexed -S = deque([0]) -for i in range(N + 1): -    c2 = A[c2] - 1 -    if c2 == c: -        break -    else: -        S.append(c2) -# print('C', C) -# print('S', S) -# print('len(C), len(S)', len(C), len(S)) -if C[0] == 0: -    mod = K % len(C) -    ans = C[mod] +A = [-1] + list(map(int, input().split())) +I = [-1] * (N + 1) +S = [] +idx = 1 +while I[idx] == -1: +    S.append(idx) +    I[idx] = len(S) +    idx = A[idx] +# print(f'{S=}, {idx=}, {I[idx]=}') +start_idx = I[idx] - 1 +num_circles = len(S) - start_idx +# print(f'{start_idx=}, {num_circles=}') +if K < len(S) - 1: +    ans = S[K] -    if len(S) > K: -        ans = S[K] -    else: -        mod = (K - len(S)) % len(C) -        ans = C[mod] -print((ans + 1)) +    K -= start_idx +    div, mod = divmod(K, num_circles) +    ans = S[start_idx + mod] +print(ans)