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

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

save = []

isSaved = [False]*(n+1)

s_queue = [[1,0]]

while(len(s_queue)>0):

    i,cnt = s_queue.pop()

    if(cnt==k):

        break

    if(isSaved[i]):

        last=mp[i-1]

        break

    nexti = mp[i-1]

    isSaved[i] = True

    save.append(nexti)

    s_queue.append([nexti,cnt+1])





ls = len(save)



if(k<=ls):

    print((save[k-1]))

else:

    for i in range(ls):

        if(save[i]==last):

            si = i

    k -= si

    save = save[si:]

    ls = len(save)

    amari = k%ls

    print((save[amari-1]))

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

A = [int(x)-1 for x in input().split()]



isSearched = [False]*n

isSearched[0] = True

ans = []

def f():

    global k

    now = 0

    nex = A[0]

    ans.append(now)

    for i in range(k):

        now = nex

        ans.append(now)

        isSearched[now] = True

        nex = A[nex]

        if(isSearched[nex]):

            break



    if((len(ans)-1)==k):

        print((ans[-1]+1))

        return

    for i in range(len(ans)):

        if(ans[i]==nex):

            savei = i

    k -= savei

    mod = len(ans) - savei

    print((ans[savei+k%mod]+1))



f()
n, k = list(map(int, input().split()))
mp = list(map(int, input().split()))
save = []
isSaved = [False] * (n + 1)
s_queue = [[1, 0]]
while len(s_queue) > 0:
    i, cnt = s_queue.pop()
    if cnt == k:
        break
    if isSaved[i]:
        last = mp[i - 1]
        break
    nexti = mp[i - 1]
    isSaved[i] = True
    save.append(nexti)
    s_queue.append([nexti, cnt + 1])
ls = len(save)
if k <= ls:
    print((save[k - 1]))
else:
    for i in range(ls):
        if save[i] == last:
            si = i
    k -= si
    save = save[si:]
    ls = len(save)
    amari = k % ls
    print((save[amari - 1]))

n, k = list(map(int, input().split()))
A = [int(x) - 1 for x in input().split()]
isSearched = [False] * n
isSearched[0] = True
ans = []


def f():
    global k
    now = 0
    nex = A[0]
    ans.append(now)
    for i in range(k):
        now = nex
        ans.append(now)
        isSearched[now] = True
        nex = A[nex]
        if isSearched[nex]:
            break
    if (len(ans) - 1) == k:
        print((ans[-1] + 1))
        return
    for i in range(len(ans)):
        if ans[i] == nex:
            savei = i
    k -= savei
    mod = len(ans) - savei
    print((ans[savei + k % mod] + 1))


f()

-mp = list(map(int, input().split())) -save = [] -isSaved = [False] * (n + 1) -s_queue = [[1, 0]] -while len(s_queue) > 0: -    i, cnt = s_queue.pop() -    if cnt == k: -        break -    if isSaved[i]: -        last = mp[i - 1] -        break -    nexti = mp[i - 1] -    isSaved[i] = True -    save.append(nexti) -    s_queue.append([nexti, cnt + 1]) -ls = len(save) -if k <= ls: -    print((save[k - 1])) -else: -    for i in range(ls): -        if save[i] == last: -            si = i -    k -= si -    save = save[si:] -    ls = len(save) -    amari = k % ls -    print((save[amari - 1])) +A = [int(x) - 1 for x in input().split()] +isSearched = [False] * n +isSearched[0] = True +ans = [] + + +def f(): +    global k +    now = 0 +    nex = A[0] +    ans.append(now) +    for i in range(k): +        now = nex +        ans.append(now) +        isSearched[now] = True +        nex = A[nex] +        if isSearched[nex]: +            break +    if (len(ans) - 1) == k: +        print((ans[-1] + 1)) +        return +    for i in range(len(ans)): +        if ans[i] == nex: +            savei = i +    k -= savei +    mod = len(ans) - savei +    print((ans[savei + k % mod] + 1)) + + +f()