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

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



R = []

done = set()

todo = [0]

done = set()

bp = None

while todo:

    p = todo.pop()

    R.append(p)

    done.add(p)

    np = A[p]

    if np in done:

        bp = np

    else:

        todo.append(np)

b = R.index(bp)

if K < b:

    ans = R[K] + 1

else:

    K -= b

    R = R[b:]

    ans = R[K%len(R)] + 1

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

A = tuple(int(x) - 1 for x in input().split())



done = {0}

rt = [0]

loop_point = 0

while True:

    p = rt[-1]

    np = A[p]

    if np in done:

        loop_point = np

        break

    done.add(np)

    rt.append(np)

if K < len(rt):

    ans = rt[K] + 1

else:

    K -= len(rt)

    rt = rt[rt.index(loop_point):]

    ans = rt[K%len(rt)] + 1

print(ans)
N, K = list(map(int, input().split()))
A = list([int(x) - 1 for x in input().split()])
R = []
done = set()
todo = [0]
done = set()
bp = None
while todo:
    p = todo.pop()
    R.append(p)
    done.add(p)
    np = A[p]
    if np in done:
        bp = np
    else:
        todo.append(np)
b = R.index(bp)
if K < b:
    ans = R[K] + 1
else:
    K -= b
    R = R[b:]
    ans = R[K % len(R)] + 1
print(ans)

N, K = list(map(int, input().split()))
A = tuple(int(x) - 1 for x in input().split())
done = {0}
rt = [0]
loop_point = 0
while True:
    p = rt[-1]
    np = A[p]
    if np in done:
        loop_point = np
        break
    done.add(np)
    rt.append(np)
if K < len(rt):
    ans = rt[K] + 1
else:
    K -= len(rt)
    rt = rt[rt.index(loop_point) :]
    ans = rt[K % len(rt)] + 1
print(ans)

-A = list([int(x) - 1 for x in input().split()]) -R = [] -done = set() -todo = [0] -done = set() -bp = None -while todo: -    p = todo.pop() -    R.append(p) -    done.add(p) +A = tuple(int(x) - 1 for x in input().split()) +done = {0} +rt = [0] +loop_point = 0 +while True: +    p = rt[-1] -        bp = np -    else: -        todo.append(np) -b = R.index(bp) -if K < b: -    ans = R[K] + 1 +        loop_point = np +        break +    done.add(np) +    rt.append(np) +if K < len(rt): +    ans = rt[K] + 1 -    K -= b -    R = R[b:] -    ans = R[K % len(R)] + 1 +    K -= len(rt) +    rt = rt[rt.index(loop_point) :] +    ans = rt[K % len(rt)] + 1