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



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



memo = [0]*(n+1)



for i in range(n):

    memo[i+1] = t[i]



move = 1



count = 0



check = [0]*(n+1)



while check[move] == 0 and count < k-1:

    check[move] += 1

    move=memo[move]

    count += 1



if k == count:

    print((memo[move]))

else:

    count2 = 0

    check = [0]*(n+1)

    move_log = []

    while check[move] == 0:

        move_log.append(move)

        check[move] += 1

        move=memo[move]

        count2 += 1

    print((move_log[(k-count)%count2]))

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



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



check = [0]*N



jump = 0



count = 0



while check[A[jump]-1] == 0 and count < K:

    n_jump = A[jump]-1

    check[n_jump] = check[jump]+1

    count += 1

    jump = n_jump



if count == K:

    key = max(check)

    ans = check.index(key)+1

else:

    count2 = 0

    key = max(check)

    jump = check.index(key)

    check2 = [0]*N

    while check2[A[jump]-1] == 0:

        n_jump = A[jump]-1

        check2[n_jump] = check2[jump]+1

        count2 += 1

        jump = n_jump

    amari = (K-count)%count2

    if amari == 0:

        key = max(check2)

        ans = check2.index(key)+1

    else:

        ans = check2.index(amari)+1

print(ans)

    
n, k = list(map(int, input().split()))
t = list(map(int, input().split()))
memo = [0] * (n + 1)
for i in range(n):
    memo[i + 1] = t[i]
move = 1
count = 0
check = [0] * (n + 1)
while check[move] == 0 and count < k - 1:
    check[move] += 1
    move = memo[move]
    count += 1
if k == count:
    print((memo[move]))
else:
    count2 = 0
    check = [0] * (n + 1)
    move_log = []
    while check[move] == 0:
        move_log.append(move)
        check[move] += 1
        move = memo[move]
        count2 += 1
    print((move_log[(k - count) % count2]))

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
check = [0] * N
jump = 0
count = 0
while check[A[jump] - 1] == 0 and count < K:
    n_jump = A[jump] - 1
    check[n_jump] = check[jump] + 1
    count += 1
    jump = n_jump
if count == K:
    key = max(check)
    ans = check.index(key) + 1
else:
    count2 = 0
    key = max(check)
    jump = check.index(key)
    check2 = [0] * N
    while check2[A[jump] - 1] == 0:
        n_jump = A[jump] - 1
        check2[n_jump] = check2[jump] + 1
        count2 += 1
        jump = n_jump
    amari = (K - count) % count2
    if amari == 0:
        key = max(check2)
        ans = check2.index(key) + 1
    else:
        ans = check2.index(amari) + 1
print(ans)

-n, k = list(map(int, input().split())) -t = list(map(int, input().split())) -memo = [0] * (n + 1) -for i in range(n): -    memo[i + 1] = t[i] -move = 1 +N, K = list(map(int, input().split())) +A = list(map(int, input().split())) +check = [0] * N +jump = 0 -check = [0] * (n + 1) -while check[move] == 0 and count < k - 1: -    check[move] += 1 -    move = memo[move] +while check[A[jump] - 1] == 0 and count < K: +    n_jump = A[jump] - 1 +    check[n_jump] = check[jump] + 1 -if k == count: -    print((memo[move])) +    jump = n_jump +if count == K: +    key = max(check) +    ans = check.index(key) + 1 -    check = [0] * (n + 1) -    move_log = [] -    while check[move] == 0: -        move_log.append(move) -        check[move] += 1 -        move = memo[move] +    key = max(check) +    jump = check.index(key) +    check2 = [0] * N +    while check2[A[jump] - 1] == 0: +        n_jump = A[jump] - 1 +        check2[n_jump] = check2[jump] + 1 -    print((move_log[(k - count) % count2])) +        jump = n_jump +    amari = (K - count) % count2 +    if amari == 0: +        key = max(check2) +        ans = check2.index(key) + 1 +    else: +        ans = check2.index(amari) + 1 +print(ans)