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

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

loc = 0

lst = [False]*n

lst[0] = True

while True:

    if lst[a[loc]]:

        x = a[loc]

        break

    loc = a[loc]

    lst[loc] = True

cnt = 0

loc = 0

if x != 0:

    while True:

        loc = a[loc]

        cnt += 1

        if loc == x: break

cnt2 = 0

while True:

    loc = a[loc]

    cnt2 += 1

    if loc == x: break

if k >= cnt:

    k -= cnt

    k %= cnt2

    loc = x

    while k > 0:

        loc = a[loc]

        k -= 1

else:

    loc = 0

    while k > 0:

        loc = a[loc]

        k -= 1

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

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

seen = []

cnt = [-1]*n

now = 0

while cnt[now] == -1:

    cnt[now] = len(seen)

    seen.append(now)

    now = a[now]

loop = len(seen)-cnt[now]

toloop = cnt[now]

if k <= toloop:

    ans = seen[k] + 1

else:

    k = (k-toloop)%loop

    ans = seen[toloop+k] + 1

print(ans)
n, k = list(map(int, input().split()))
a = [int(i) - 1 for i in input().split()]
loc = 0
lst = [False] * n
lst[0] = True
while True:
    if lst[a[loc]]:
        x = a[loc]
        break
    loc = a[loc]
    lst[loc] = True
cnt = 0
loc = 0
if x != 0:
    while True:
        loc = a[loc]
        cnt += 1
        if loc == x:
            break
cnt2 = 0
while True:
    loc = a[loc]
    cnt2 += 1
    if loc == x:
        break
if k >= cnt:
    k -= cnt
    k %= cnt2
    loc = x
    while k > 0:
        loc = a[loc]
        k -= 1
else:
    loc = 0
    while k > 0:
        loc = a[loc]
        k -= 1
print((loc + 1))

n, k = list(map(int, input().split()))
a = [int(i) - 1 for i in input().split()]
seen = []
cnt = [-1] * n
now = 0
while cnt[now] == -1:
    cnt[now] = len(seen)
    seen.append(now)
    now = a[now]
loop = len(seen) - cnt[now]
toloop = cnt[now]
if k <= toloop:
    ans = seen[k] + 1
else:
    k = (k - toloop) % loop
    ans = seen[toloop + k] + 1
print(ans)

-loc = 0 -lst = [False] * n -lst[0] = True -while True: -    if lst[a[loc]]: -        x = a[loc] -        break -    loc = a[loc] -    lst[loc] = True -cnt = 0 -loc = 0 -if x != 0: -    while True: -        loc = a[loc] -        cnt += 1 -        if loc == x: -            break -cnt2 = 0 -while True: -    loc = a[loc] -    cnt2 += 1 -    if loc == x: -        break -if k >= cnt: -    k -= cnt -    k %= cnt2 -    loc = x -    while k > 0: -        loc = a[loc] -        k -= 1 +seen = [] +cnt = [-1] * n +now = 0 +while cnt[now] == -1: +    cnt[now] = len(seen) +    seen.append(now) +    now = a[now] +loop = len(seen) - cnt[now] +toloop = cnt[now] +if k <= toloop: +    ans = seen[k] + 1 -    loc = 0 -    while k > 0: -        loc = a[loc] -        k -= 1 -print((loc + 1)) +    k = (k - toloop) % loop +    ans = seen[toloop + k] + 1 +print(ans)