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

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



cnt, pre = [0]*N, 0

for _ in range(N*2):

    cnt[pre] += 1

    pre = A[pre]



one, loops = 0, 0

for c in cnt:

    if c == 1: one += 1

    elif c > 1: loops += 1



k = max(0, K-one) % loops + min(K, one)



pre = 0

for _ in range(k): pre = A[pre]

print((pre + 1))

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

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



pre = 0

index = [-1]*N

path = []

for n in range(N):

    if index[pre] >= 0:

        # print('len(path)',len(path),'pre',pre)

        # print('n',n,'index[pre]',index[pre])

        # print('index',index)

        # print('path',path)

        break

    else:

        index[pre] = n

        path += [pre]

    pre = A[pre]



loops = len(path) - index[pre]

one = len(path) - loops

k = max(0, K-one) % loops + min(K, one)

# print('one',one,'loops',loops,'k',k)



pre = 0

for _ in range(k): pre = A[pre]

print((pre + 1))

N, K = list(map(int, input().split()))
A = [*[int(x) - 1 for x in input().split()]]
cnt, pre = [0] * N, 0
for _ in range(N * 2):
    cnt[pre] += 1
    pre = A[pre]
one, loops = 0, 0
for c in cnt:
    if c == 1:
        one += 1
    elif c > 1:
        loops += 1
k = max(0, K - one) % loops + min(K, one)
pre = 0
for _ in range(k):
    pre = A[pre]
print((pre + 1))

N, K = list(map(int, input().split()))
A = [*[int(x) - 1 for x in input().split()]]
pre = 0
index = [-1] * N
path = []
for n in range(N):
    if index[pre] >= 0:
        # print('len(path)',len(path),'pre',pre)
        # print('n',n,'index[pre]',index[pre])
        # print('index',index)
        # print('path',path)
        break
    else:
        index[pre] = n
        path += [pre]
    pre = A[pre]
loops = len(path) - index[pre]
one = len(path) - loops
k = max(0, K - one) % loops + min(K, one)
# print('one',one,'loops',loops,'k',k)
pre = 0
for _ in range(k):
    pre = A[pre]
print((pre + 1))

-cnt, pre = [0] * N, 0 -for _ in range(N * 2): -    cnt[pre] += 1 +pre = 0 +index = [-1] * N +path = [] +for n in range(N): +    if index[pre] >= 0: +        # print('len(path)',len(path),'pre',pre) +        # print('n',n,'index[pre]',index[pre]) +        # print('index',index) +        # print('path',path) +        break +    else: +        index[pre] = n +        path += [pre] -one, loops = 0, 0 -for c in cnt: -    if c == 1: -        one += 1 -    elif c > 1: -        loops += 1 +loops = len(path) - index[pre] +one = len(path) - loops +# print('one',one,'loops',loops,'k',k)