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

a = [int(i) - 1 for i in input().split()]

ans = 0

while k:

    if k & 1:

        ans = a[ans]

    c = [a[a[i]] for i in range(n)]

    a = c[:]

    k >>= 1

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

a = [int(i) for i in input().split()]

s = []

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

c, l = 1, 0

v = 1

while (ord[v] == -1):

    ord[v] = len(s)

    s.append(v)

    v = a[v-1]

    

c = len(s) - ord[v]

l = ord[v]

print((s[k] if (k < l) else s[l + (k - l) % c]))
n, k = list(map(int, input().split()))
a = [int(i) - 1 for i in input().split()]
ans = 0
while k:
    if k & 1:
        ans = a[ans]
    c = [a[a[i]] for i in range(n)]
    a = c[:]
    k >>= 1
print((ans + 1))

n, k = list(map(int, input().split()))
a = [int(i) for i in input().split()]
s = []
ord = [-1] * (n + 1)
c, l = 1, 0
v = 1
while ord[v] == -1:
    ord[v] = len(s)
    s.append(v)
    v = a[v - 1]
c = len(s) - ord[v]
l = ord[v]
print((s[k] if (k < l) else s[l + (k - l) % c]))

-a = [int(i) - 1 for i in input().split()] -ans = 0 -while k: -    if k & 1: -        ans = a[ans] -    c = [a[a[i]] for i in range(n)] -    a = c[:] -    k >>= 1 -print((ans + 1)) +a = [int(i) for i in input().split()] +s = [] +ord = [-1] * (n + 1) +c, l = 1, 0 +v = 1 +while ord[v] == -1: +    ord[v] = len(s) +    s.append(v) +    v = a[v - 1] +c = len(s) - ord[v] +l = ord[v] +print((s[k] if (k < l) else s[l + (k - l) % c]))