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

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



num = 1

li = [1]

flag = [True] * n

flag[0] = False



for i in range(k):

    num = a[num-1]

    if flag[num-1]:

        li.append(num)

        flag[num-1] = False

    else:

        break



d = li.index(num)

ans = (k-d)%(len(li)-d)+d



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

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



tt = [0] * n

tt[0] = 1

ans_l = [1]

i = 1



for j in range(k):

    i = a[i-1]

    if tt[i-1] == False:

        tt[i-1] = 1

        ans_l.append(i)

    else:

        break



d = ans_l.index(i)

k -= d

ans = k % (len(ans_l)-d)

print((ans_l[ans+d]))

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
num = 1
li = [1]
flag = [True] * n
flag[0] = False
for i in range(k):
    num = a[num - 1]
    if flag[num - 1]:
        li.append(num)
        flag[num - 1] = False
    else:
        break
d = li.index(num)
ans = (k - d) % (len(li) - d) + d
print((li[ans]))

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
tt = [0] * n
tt[0] = 1
ans_l = [1]
i = 1
for j in range(k):
    i = a[i - 1]
    if tt[i - 1] == False:
        tt[i - 1] = 1
        ans_l.append(i)
    else:
        break
d = ans_l.index(i)
k -= d
ans = k % (len(ans_l) - d)
print((ans_l[ans + d]))

-num = 1 -li = [1] -flag = [True] * n -flag[0] = False -for i in range(k): -    num = a[num - 1] -    if flag[num - 1]: -        li.append(num) -        flag[num - 1] = False +tt = [0] * n +tt[0] = 1 +ans_l = [1] +i = 1 +for j in range(k): +    i = a[i - 1] +    if tt[i - 1] == False: +        tt[i - 1] = 1 +        ans_l.append(i) -d = li.index(num) -ans = (k - d) % (len(li) - d) + d -print((li[ans])) +d = ans_l.index(i) +k -= d +ans = k % (len(ans_l) - d) +print((ans_l[ans + d]))