N, K = list(map(int, input().split()))

A = [0] + list(map(int, input().split()))

 

s = [0] * (N+1)

p = 1

h = []

for i in range(K):

    h.append(p)

    s[p] = 1

    p = A[p]



    if s[p] != 0:

        break



if i == K-1:

    print(p)

    exit()

else: 

    period = len(h) - h.index(p)

    rem = (K - h.index(p)) % period

    print((h[h.index(p):][rem]))

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

a = [0] + list(map(int, input().split()))



seen = [False] * (n+1)

visited = []

nxt = 1

cnt = 0

while not seen[nxt] and cnt != k:

    seen[nxt] = True

    visited.append(nxt)

    nxt = a[nxt]

    cnt += 1



if cnt == k:

    print(nxt)

    exit()

    

idx = visited.index(nxt)

print((visited[idx:][(k-idx)%(len(visited)-idx)]))

N, K = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))
s = [0] * (N + 1)
p = 1
h = []
for i in range(K):
    h.append(p)
    s[p] = 1
    p = A[p]
    if s[p] != 0:
        break
if i == K - 1:
    print(p)
    exit()
else:
    period = len(h) - h.index(p)
    rem = (K - h.index(p)) % period
    print((h[h.index(p) :][rem]))

n, k = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
seen = [False] * (n + 1)
visited = []
nxt = 1
cnt = 0
while not seen[nxt] and cnt != k:
    seen[nxt] = True
    visited.append(nxt)
    nxt = a[nxt]
    cnt += 1
if cnt == k:
    print(nxt)
    exit()
idx = visited.index(nxt)
print((visited[idx:][(k - idx) % (len(visited) - idx)]))

-N, K = list(map(int, input().split())) -A = [0] + list(map(int, input().split())) -s = [0] * (N + 1) -p = 1 -h = [] -for i in range(K): -    h.append(p) -    s[p] = 1 -    p = A[p] -    if s[p] != 0: -        break -if i == K - 1: -    print(p) +n, k = list(map(int, input().split())) +a = [0] + list(map(int, input().split())) +seen = [False] * (n + 1) +visited = [] +nxt = 1 +cnt = 0 +while not seen[nxt] and cnt != k: +    seen[nxt] = True +    visited.append(nxt) +    nxt = a[nxt] +    cnt += 1 +if cnt == k: +    print(nxt) -else: -    period = len(h) - h.index(p) -    rem = (K - h.index(p)) % period -    print((h[h.index(p) :][rem])) +idx = visited.index(nxt) +print((visited[idx:][(k - idx) % (len(visited) - idx)]))