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

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

A = [x-1 for x in A]



town = 0

cnt = 0



# memo = []

# visited = [False] * n

# visited[0] = -1



# start = 0

# loop = 10**8

# start_cnt = 0

# for i in range(n*2):

#     town = A[town]

#     memo.append(town)

#     if visited[town] != False:

#         start_cnt = i + 1

#         loop = i - visited[town]

#         break

#     else:

#         visited[town] = i

#

# for i in range((k-start_cnt)%loop):

#     town = A[town]

#

# print(town+1)



visited = [False] * n

visited[0] = 0



for i in range(n):

    town = A[town]

    if visited[town]:

        good_town = town

        break

    visited[town] = i+1



town = good_town



for i in range(n):

    town = A[town]

    if town == good_town:

        loop = i + 1



if k >= visited[good_town]:

    k = ((k-visited[good_town])%loop)+visited[good_town]





town = 0

for i in range(k):

    town = A[town]

print((town+1))
n, k = list(map(int, input().split()))

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

A = [x-1 for x in A]



town = 0

cnt = 0



visited = [False] * n

visited[0] = -1



start_cnt = 0

for i in range(n*2):

    town = A[town]

    if visited[town] != False:

        start_cnt = i + 1

        loop = i - visited[town]

        break

    else:

        visited[town] = i



town = 0



if k >= start_cnt:

    k = (k-start_cnt)%loop+start_cnt



for i in range(k):

    town = A[town]



print((town+1))

n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [x - 1 for x in A]
town = 0
cnt = 0
# memo = []
# visited = [False] * n
# visited[0] = -1
# start = 0
# loop = 10**8
# start_cnt = 0
# for i in range(n*2):
#     town = A[town]
#     memo.append(town)
#     if visited[town] != False:
#         start_cnt = i + 1
#         loop = i - visited[town]
#         break
#     else:
#         visited[town] = i
#
# for i in range((k-start_cnt)%loop):
#     town = A[town]
#
# print(town+1)
visited = [False] * n
visited[0] = 0
for i in range(n):
    town = A[town]
    if visited[town]:
        good_town = town
        break
    visited[town] = i + 1
town = good_town
for i in range(n):
    town = A[town]
    if town == good_town:
        loop = i + 1
if k >= visited[good_town]:
    k = ((k - visited[good_town]) % loop) + visited[good_town]
town = 0
for i in range(k):
    town = A[town]
print((town + 1))

n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [x - 1 for x in A]
town = 0
cnt = 0
visited = [False] * n
visited[0] = -1
start_cnt = 0
for i in range(n * 2):
    town = A[town]
    if visited[town] != False:
        start_cnt = i + 1
        loop = i - visited[town]
        break
    else:
        visited[town] = i
town = 0
if k >= start_cnt:
    k = (k - start_cnt) % loop + start_cnt
for i in range(k):
    town = A[town]
print((town + 1))

-# memo = [] -# visited = [False] * n -# visited[0] = -1 -# start = 0 -# loop = 10**8 -# start_cnt = 0 -# for i in range(n*2): -#     town = A[town] -#     memo.append(town) -#     if visited[town] != False: -#         start_cnt = i + 1 -#         loop = i - visited[town] -#         break -#     else: -#         visited[town] = i -# -# for i in range((k-start_cnt)%loop): -#     town = A[town] -# -# print(town+1) -visited[0] = 0 -for i in range(n): +visited[0] = -1 +start_cnt = 0 +for i in range(n * 2): -    if visited[town]: -        good_town = town +    if visited[town] != False: +        start_cnt = i + 1 +        loop = i - visited[town] -    visited[town] = i + 1 -town = good_town -for i in range(n): -    town = A[town] -    if town == good_town: -        loop = i + 1 -if k >= visited[good_town]: -    k = ((k - visited[good_town]) % loop) + visited[good_town] +    else: +        visited[town] = i +if k >= start_cnt: +    k = (k - start_cnt) % loop + start_cnt