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

routs = {}

location = [0 for i in range(N + 1)]

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

for i in range(N):

  routs[i] = tereporter[i] - 1

present_location = 0

n = 0

for i in range(K):

  n += 1

  present_location = routs[present_location]

  if location[present_location] == 0:

    location[present_location] = n

  else:

    loop = n - location[present_location]

    if (K - location[present_location]) % loop == 0:

      break

    else:

      for i in range((K - location[present_location]) % loop):

        present_location = routs[present_location]

      break

print((present_location + 1))
N, K = list(map(int, input().split()))

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

n = 0

present = 0

praces = [-1 for i in range(N)]

praces[0] = 0

for i in range(K):

  present = teleporters[present] - 1

  n += 1

  if praces[present] == -1:

    praces[present] = n

  else:

    before = praces[present]

    loop = n - before

    remainder = (K - before) % loop

    present = praces.index(before + remainder)

    break

print((present + 1))
N, K = list(map(int, input().split(" ")))
routs = {}
location = [0 for i in range(N + 1)]
tereporter = list(map(int, input().split()))
for i in range(N):
    routs[i] = tereporter[i] - 1
present_location = 0
n = 0
for i in range(K):
    n += 1
    present_location = routs[present_location]
    if location[present_location] == 0:
        location[present_location] = n
    else:
        loop = n - location[present_location]
        if (K - location[present_location]) % loop == 0:
            break
        else:
            for i in range((K - location[present_location]) % loop):
                present_location = routs[present_location]
            break
print((present_location + 1))

N, K = list(map(int, input().split()))
teleporters = list(map(int, input().split()))
n = 0
present = 0
praces = [-1 for i in range(N)]
praces[0] = 0
for i in range(K):
    present = teleporters[present] - 1
    n += 1
    if praces[present] == -1:
        praces[present] = n
    else:
        before = praces[present]
        loop = n - before
        remainder = (K - before) % loop
        present = praces.index(before + remainder)
        break
print((present + 1))

-N, K = list(map(int, input().split(" "))) -routs = {} -location = [0 for i in range(N + 1)] -tereporter = list(map(int, input().split())) -for i in range(N): -    routs[i] = tereporter[i] - 1 -present_location = 0 +N, K = list(map(int, input().split())) +teleporters = list(map(int, input().split())) +present = 0 +praces = [-1 for i in range(N)] +praces[0] = 0 +    present = teleporters[present] - 1 -    present_location = routs[present_location] -    if location[present_location] == 0: -        location[present_location] = n +    if praces[present] == -1: +        praces[present] = n -        loop = n - location[present_location] -        if (K - location[present_location]) % loop == 0: -            break -        else: -            for i in range((K - location[present_location]) % loop): -                present_location = routs[present_location] -            break -print((present_location + 1)) +        before = praces[present] +        loop = n - before +        remainder = (K - before) % loop +        present = praces.index(before + remainder) +        break +print((present + 1))