import sys

input = sys.stdin.readline

sys.setrecursionlimit(10**7)



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

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

def f(i):

  if i == 1:

    return A

  L = [-1]*(n+1)

  if i & 1:

    F = f(i-1)

    for j in range(n+1):

      L[j] = A[F[j]]

  else:

    F = f(i//2)

    for j in range(n+1):

      L[j] = F[F[j]]

  return L

F = f(k)

ans = F[1]

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

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

D = [1]

seen = [0]*n

seen[0] = 1

now = 0

while True:

    now = A[now] - 1

    D.append(now+1)

    if seen[now]:

        break

    seen[now] = 1

f = D.index(D[-1])

if k < f:

    print((D[k]))

else:

    cycle = len(D) - f - 1

    k -= f

    print((D[f + k%(cycle)]))
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, k = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))


def f(i):
    if i == 1:
        return A
    L = [-1] * (n + 1)
    if i & 1:
        F = f(i - 1)
        for j in range(n + 1):
            L[j] = A[F[j]]
    else:
        F = f(i // 2)
        for j in range(n + 1):
            L[j] = F[F[j]]
    return L


F = f(k)
ans = F[1]
print(ans)

n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
D = [1]
seen = [0] * n
seen[0] = 1
now = 0
while True:
    now = A[now] - 1
    D.append(now + 1)
    if seen[now]:
        break
    seen[now] = 1
f = D.index(D[-1])
if k < f:
    print((D[k]))
else:
    cycle = len(D) - f - 1
    k -= f
    print((D[f + k % (cycle)]))

-import sys - -input = sys.stdin.readline -sys.setrecursionlimit(10**7) -A = [0] + list(map(int, input().split())) - - -def f(i): -    if i == 1: -        return A -    L = [-1] * (n + 1) -    if i & 1: -        F = f(i - 1) -        for j in range(n + 1): -            L[j] = A[F[j]] -    else: -        F = f(i // 2) -        for j in range(n + 1): -            L[j] = F[F[j]] -    return L - - -F = f(k) -ans = F[1] -print(ans) +A = list(map(int, input().split())) +D = [1] +seen = [0] * n +seen[0] = 1 +now = 0 +while True: +    now = A[now] - 1 +    D.append(now + 1) +    if seen[now]: +        break +    seen[now] = 1 +f = D.index(D[-1]) +if k < f: +    print((D[k])) +else: +    cycle = len(D) - f - 1 +    k -= f +    print((D[f + k % (cycle)]))