from collections import deque

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

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

g = [i for i in range(n)]

for i in range(n):

    g[i] = a[i]-1

dist =[-1]*n

dist[0] = 0

q = deque([0])

hajimari = -1

loopnum = -1

while q:

    v = q.popleft()

    u = g[v]

    if dist[u] == -1:

        dist[u] = dist[v]+1

        q.append(u)

    else:

        hajimari = u

        loopnum = dist[v] + 1 - dist[u]

        break

    if hajimari != -1:

        break

if k <= dist[hajimari]:

    now = 0

    for _ in range(k):

        now = g[now]

    print((now+1))

else:

    now = hajimari

    for _ in range((k-dist[hajimari])%loopnum):

        now = g[now]

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

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

dist = [-1] * n

dist[0] = 0

now = 0

while True:

    next = a[now] - 1

    if dist[next] == -1:

        dist[next] = dist[now] + 1

    else:

        hajimari = next

        loopnum = dist[now] + 1 - dist[hajimari]

        town = 0

        if k <= dist[hajimari]:

            for _ in range(k):

                town = a[town] - 1

        else:

            town = hajimari

            for _ in range((k - dist[hajimari]) % loopnum):

                town = a[town] - 1

        print((town + 1))

        exit()

    now = next
from collections import deque

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
g = [i for i in range(n)]
for i in range(n):
    g[i] = a[i] - 1
dist = [-1] * n
dist[0] = 0
q = deque([0])
hajimari = -1
loopnum = -1
while q:
    v = q.popleft()
    u = g[v]
    if dist[u] == -1:
        dist[u] = dist[v] + 1
        q.append(u)
    else:
        hajimari = u
        loopnum = dist[v] + 1 - dist[u]
        break
    if hajimari != -1:
        break
if k <= dist[hajimari]:
    now = 0
    for _ in range(k):
        now = g[now]
    print((now + 1))
else:
    now = hajimari
    for _ in range((k - dist[hajimari]) % loopnum):
        now = g[now]
    print((now + 1))

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
dist = [-1] * n
dist[0] = 0
now = 0
while True:
    next = a[now] - 1
    if dist[next] == -1:
        dist[next] = dist[now] + 1
    else:
        hajimari = next
        loopnum = dist[now] + 1 - dist[hajimari]
        town = 0
        if k <= dist[hajimari]:
            for _ in range(k):
                town = a[town] - 1
        else:
            town = hajimari
            for _ in range((k - dist[hajimari]) % loopnum):
                town = a[town] - 1
        print((town + 1))
        exit()
    now = next

-from collections import deque - -g = [i for i in range(n)] -for i in range(n): -    g[i] = a[i] - 1 -q = deque([0]) -hajimari = -1 -loopnum = -1 -while q: -    v = q.popleft() -    u = g[v] -    if dist[u] == -1: -        dist[u] = dist[v] + 1 -        q.append(u) +now = 0 +while True: +    next = a[now] - 1 +    if dist[next] == -1: +        dist[next] = dist[now] + 1 -        hajimari = u -        loopnum = dist[v] + 1 - dist[u] -        break -    if hajimari != -1: -        break -if k <= dist[hajimari]: -    now = 0 -    for _ in range(k): -        now = g[now] -    print((now + 1)) -else: -    now = hajimari -    for _ in range((k - dist[hajimari]) % loopnum): -        now = g[now] -    print((now + 1)) +        hajimari = next +        loopnum = dist[now] + 1 - dist[hajimari] +        town = 0 +        if k <= dist[hajimari]: +            for _ in range(k): +                town = a[town] - 1 +        else: +            town = hajimari +            for _ in range((k - dist[hajimari]) % loopnum): +                town = a[town] - 1 +        print((town + 1)) +        exit() +    now = next