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

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



t = [1]

for i in range(n):

    t.append(a[t[-1] -  1])



t_sort = sorted(t)

for i in range(n):

    if t_sort[i] == t_sort[i + 1]:

        b = t_sort[i]

        break



count = 0

for i in range(n):

    if t[i] == b:

        if count == 0:

            count += 1

            s_first = i

        else:

            s_second = i

            break

s = s_second - s_first



for i in range(n - s + 1):

    if t[i] == t[i + s]:

        break



if k < i:

    print((t[k]))

else:

    print((t[(k - i) % s + i]))
n, k = list(map(int, input().split()))

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

visit = [1]



for i in range(n):

    visit.append(a_list[visit[-1] - 1])



for i in range(n - 1):

    if visit[-1]  == visit[n - i - 1]:

        break

s = i + 1



for i in range(n - s):

    if visit[i] == visit[i + s]:

        break



if k < i:

    print((visit[k]))

else:

    print((visit[i + (k - i) % s]))
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
t = [1]
for i in range(n):
    t.append(a[t[-1] - 1])
t_sort = sorted(t)
for i in range(n):
    if t_sort[i] == t_sort[i + 1]:
        b = t_sort[i]
        break
count = 0
for i in range(n):
    if t[i] == b:
        if count == 0:
            count += 1
            s_first = i
        else:
            s_second = i
            break
s = s_second - s_first
for i in range(n - s + 1):
    if t[i] == t[i + s]:
        break
if k < i:
    print((t[k]))
else:
    print((t[(k - i) % s + i]))

n, k = list(map(int, input().split()))
a_list = list(map(int, input().split()))
visit = [1]
for i in range(n):
    visit.append(a_list[visit[-1] - 1])
for i in range(n - 1):
    if visit[-1] == visit[n - i - 1]:
        break
s = i + 1
for i in range(n - s):
    if visit[i] == visit[i + s]:
        break
if k < i:
    print((visit[k]))
else:
    print((visit[i + (k - i) % s]))

-a = list(map(int, input().split())) -t = [1] +a_list = list(map(int, input().split())) +visit = [1] -    t.append(a[t[-1] - 1]) -t_sort = sorted(t) -for i in range(n): -    if t_sort[i] == t_sort[i + 1]: -        b = t_sort[i] +    visit.append(a_list[visit[-1] - 1]) +for i in range(n - 1): +    if visit[-1] == visit[n - i - 1]: -count = 0 -for i in range(n): -    if t[i] == b: -        if count == 0: -            count += 1 -            s_first = i -        else: -            s_second = i -            break -s = s_second - s_first -for i in range(n - s + 1): -    if t[i] == t[i + s]: +s = i + 1 +for i in range(n - s): +    if visit[i] == visit[i + s]: -    print((t[k])) +    print((visit[k])) -    print((t[(k - i) % s + i])) +    print((visit[i + (k - i) % s]))