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

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

b = {i:[] for i in range(n)}

ans = 0

for i in range(k):

    b[a[ans]-1].append(ans)

    if len(b[a[ans]-1]) == 2:

        c = [ans]

        ans = a[ans]-1

        while ans != c[0]:

            c.append(ans)

            ans = a[ans]-1

        ans = c[(k-i) % len(c)]

        break

    ans = a[ans]-1

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

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

s = [-1]*n

c = []

ans = 0

for i in range(k):

    s[ans] = i

    c.append(ans)

    ans = a[ans] - 1

    if s[ans] >= 0:

        t = i - s[ans] + 1

        ans = c[(k-i-1) % t + s[ans]]

        break

print((ans+1))
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = {i: [] for i in range(n)}
ans = 0
for i in range(k):
    b[a[ans] - 1].append(ans)
    if len(b[a[ans] - 1]) == 2:
        c = [ans]
        ans = a[ans] - 1
        while ans != c[0]:
            c.append(ans)
            ans = a[ans] - 1
        ans = c[(k - i) % len(c)]
        break
    ans = a[ans] - 1
print((ans + 1))

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
s = [-1] * n
c = []
ans = 0
for i in range(k):
    s[ans] = i
    c.append(ans)
    ans = a[ans] - 1
    if s[ans] >= 0:
        t = i - s[ans] + 1
        ans = c[(k - i - 1) % t + s[ans]]
        break
print((ans + 1))

-b = {i: [] for i in range(n)} +s = [-1] * n +c = [] -    b[a[ans] - 1].append(ans) -    if len(b[a[ans] - 1]) == 2: -        c = [ans] -        ans = a[ans] - 1 -        while ans != c[0]: -            c.append(ans) -            ans = a[ans] - 1 -        ans = c[(k - i) % len(c)] +    s[ans] = i +    c.append(ans) +    ans = a[ans] - 1 +    if s[ans] >= 0: +        t = i - s[ans] + 1 +        ans = c[(k - i - 1) % t + s[ans]] -    ans = a[ans] - 1