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

A = list(map(int, ("0 "+eval(input())).split()))





c = [0]*(N+1)

i = 1

cnt = 0

f = True



while cnt < K:

    if f and (c[A[i]] or A[i]==1):

        loop = cnt-c[A[i]]+1

        cnt += (K-cnt-1)//loop*loop

        f = False



    cnt += 1

    i = A[i]

    c[i] = cnt



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

A = [i-1 for i in map(int, input().split())]



r = []

f = [-1]*N

now = 0

loop = 0



i = 0





while i < K:

    r.append(now)

    f[now] = i

    now = A[now]

    i += 1

    if f[now] >= 0:

        loop = i-f[now]

        nokori = K-i

        print((r[f[now]+nokori%loop]+1))

        break

else:

    print((now+1))

N, K = list(map(int, input().split()))
A = list(map(int, ("0 " + eval(input())).split()))
c = [0] * (N + 1)
i = 1
cnt = 0
f = True
while cnt < K:
    if f and (c[A[i]] or A[i] == 1):
        loop = cnt - c[A[i]] + 1
        cnt += (K - cnt - 1) // loop * loop
        f = False
    cnt += 1
    i = A[i]
    c[i] = cnt
print(i)

N, K = list(map(int, input().split()))
A = [i - 1 for i in map(int, input().split())]
r = []
f = [-1] * N
now = 0
loop = 0
i = 0
while i < K:
    r.append(now)
    f[now] = i
    now = A[now]
    i += 1
    if f[now] >= 0:
        loop = i - f[now]
        nokori = K - i
        print((r[f[now] + nokori % loop] + 1))
        break
else:
    print((now + 1))

-A = list(map(int, ("0 " + eval(input())).split())) -c = [0] * (N + 1) -i = 1 -cnt = 0 -f = True -while cnt < K: -    if f and (c[A[i]] or A[i] == 1): -        loop = cnt - c[A[i]] + 1 -        cnt += (K - cnt - 1) // loop * loop -        f = False -    cnt += 1 -    i = A[i] -    c[i] = cnt -print(i) +A = [i - 1 for i in map(int, input().split())] +r = [] +f = [-1] * N +now = 0 +loop = 0 +i = 0 +while i < K: +    r.append(now) +    f[now] = i +    now = A[now] +    i += 1 +    if f[now] >= 0: +        loop = i - f[now] +        nokori = K - i +        print((r[f[now] + nokori % loop] + 1)) +        break +else: +    print((now + 1))