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

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



time=0

color=["white" for _ in range(n+1)]

D=[-1 for _ in range(n+1)]

C,s=[],A[0]

point=0

while 1:

    if color[s]=="white":

        color[s]="gray"

        C.append(s)

        D[s]=time

        time +=1

        s=A[s-1]

    else:

        point=D[s]

        break



loop=C[point:]

if k>len(C):

    k -=point+1

    print((loop[k%len(loop)]))

else:print((C[k-1]))
n,k=list(map(int,input().split()))

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



time=0

color=["white" for _ in range(n+1)]

D=[-1 for _ in range(n+1)]

C,s=[],A[0]

point=0

while 1:

    if color[s]=="white":

        color[s]="gray"

        C.append(s)

        D[s]=time

        time +=1

        s=A[s-1]

    else:

        point=D[s]

        break



loop=C[point:]

if k>len(C):

    k -=point

    print((loop[k%len(loop)-1]))

else:print((C[k-1]))
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
time = 0
color = ["white" for _ in range(n + 1)]
D = [-1 for _ in range(n + 1)]
C, s = [], A[0]
point = 0
while 1:
    if color[s] == "white":
        color[s] = "gray"
        C.append(s)
        D[s] = time
        time += 1
        s = A[s - 1]
    else:
        point = D[s]
        break
loop = C[point:]
if k > len(C):
    k -= point + 1
    print((loop[k % len(loop)]))
else:
    print((C[k - 1]))

n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
time = 0
color = ["white" for _ in range(n + 1)]
D = [-1 for _ in range(n + 1)]
C, s = [], A[0]
point = 0
while 1:
    if color[s] == "white":
        color[s] = "gray"
        C.append(s)
        D[s] = time
        time += 1
        s = A[s - 1]
    else:
        point = D[s]
        break
loop = C[point:]
if k > len(C):
    k -= point
    print((loop[k % len(loop) - 1]))
else:
    print((C[k - 1]))

-    k -= point + 1 -    print((loop[k % len(loop)])) +    k -= point +    print((loop[k % len(loop) - 1]))