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



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

a1 = [0] * (n+1)



step = 1

start = 0

while(True):

    start += 1

    a1[step] += 1

    step = a[step]

    if a1[step] == 1:

        break

c = step

gap = 0

while(True):

    gap += 1

    step = a[step]

    if step == c:

        break

result = 1

if k > start:

    k = (k-start) % gap

    result = c

for _ in range(k):

    result = a[result]



print(result)

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

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



repeat = [0] * (n+1)

circle = [1]

point = 1

flag = 0

for _ in range(k):

    circle.append(a[point])

    repeat[point] = 1

    point = a[point]

    if(repeat[point] == 1):

        flag = 1

        break



if flag == 0:

    print((circle[-1]))

else:

    index = circle.index(point)

    circle_cut = circle[index:-1]

    k = (k-index) % len(circle_cut)

    print((circle_cut[k]))

n, k = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
a1 = [0] * (n + 1)
step = 1
start = 0
while True:
    start += 1
    a1[step] += 1
    step = a[step]
    if a1[step] == 1:
        break
c = step
gap = 0
while True:
    gap += 1
    step = a[step]
    if step == c:
        break
result = 1
if k > start:
    k = (k - start) % gap
    result = c
for _ in range(k):
    result = a[result]
print(result)

n, k = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
repeat = [0] * (n + 1)
circle = [1]
point = 1
flag = 0
for _ in range(k):
    circle.append(a[point])
    repeat[point] = 1
    point = a[point]
    if repeat[point] == 1:
        flag = 1
        break
if flag == 0:
    print((circle[-1]))
else:
    index = circle.index(point)
    circle_cut = circle[index:-1]
    k = (k - index) % len(circle_cut)
    print((circle_cut[k]))

-a1 = [0] * (n + 1) -step = 1 -start = 0 -while True: -    start += 1 -    a1[step] += 1 -    step = a[step] -    if a1[step] == 1: +repeat = [0] * (n + 1) +circle = [1] +point = 1 +flag = 0 +for _ in range(k): +    circle.append(a[point]) +    repeat[point] = 1 +    point = a[point] +    if repeat[point] == 1: +        flag = 1 -c = step -gap = 0 -while True: -    gap += 1 -    step = a[step] -    if step == c: -        break -result = 1 -if k > start: -    k = (k - start) % gap -    result = c -for _ in range(k): -    result = a[result] -print(result) +if flag == 0: +    print((circle[-1])) +else: +    index = circle.index(point) +    circle_cut = circle[index:-1] +    k = (k - index) % len(circle_cut) +    print((circle_cut[k]))