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

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

d = dict()

c = 1

loop = False

k = 0

while(k<K):



    if not loop and str(c) in d:

        T = k-d[str(c)]

        #print ('K',k)

        a =  max((((K-k) // T)) - 1,0)

        #print(a)

        k += a*T

        #print ('K',k)

        loop = True

    d[str(c)] = k

    c = A[c]

    k+=1

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

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

turn = [-1] * (N+1) # いつ訪問したかを記録する

c = 1

for k in range(K):

    if turn[c]!=-1:

        T = k - turn[c] # 周期

        bias = turn[c] # バイアス

        break

    turn[c] = k

    c = A[c]

else:

    print (c)

    exit()



K -= bias # Kを減らしてリスタート

K %= T

K += bias

c = 1 

for k in range(K):

    c = A[c]

print (c)

N, K = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))
d = dict()
c = 1
loop = False
k = 0
while k < K:
    if not loop and str(c) in d:
        T = k - d[str(c)]
        # print ('K',k)
        a = max((((K - k) // T)) - 1, 0)
        # print(a)
        k += a * T
        # print ('K',k)
        loop = True
    d[str(c)] = k
    c = A[c]
    k += 1
print(c)

N, K = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))
turn = [-1] * (N + 1)  # いつ訪問したかを記録する
c = 1
for k in range(K):
    if turn[c] != -1:
        T = k - turn[c]  # 周期
        bias = turn[c]  # バイアス
        break
    turn[c] = k
    c = A[c]
else:
    print(c)
    exit()
K -= bias  # Kを減らしてリスタート
K %= T
K += bias
c = 1
for k in range(K):
    c = A[c]
print(c)

-d = dict() +turn = [-1] * (N + 1)  # いつ訪問したかを記録する -loop = False -k = 0 -while k < K: -    if not loop and str(c) in d: -        T = k - d[str(c)] -        # print ('K',k) -        a = max((((K - k) // T)) - 1, 0) -        # print(a) -        k += a * T -        # print ('K',k) -        loop = True -    d[str(c)] = k +for k in range(K): +    if turn[c] != -1: +        T = k - turn[c]  # 周期 +        bias = turn[c]  # バイアス +        break +    turn[c] = k -    k += 1 +else: +    print(c) +    exit() +K -= bias  # Kを減らしてリスタート +K %= T +K += bias +c = 1 +for k in range(K): +    c = A[c]