import numpy as np



def main():

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

    A = [0]

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

    A = np.array(A)

    

    i = 1

    pas = np.zeros(N)

    pas[0] = i

    k = 1

    pass_set = set(pas)

    while k <= K:

        if A[i] in pass_set:

            rps = np.where(pas==(A[i]))[0]

            ans = A[i]

            break

        pas[k] = A[i]

        pass_set.add(A[i])

        ans = A[i]

        i = A[i]

        k += 1



    if k >= K:

        print(ans)

    else:

        rpnum = (K-rps[0])%(k-rps)

        print((int(pas[rps[0]+rpnum])))



main()
def main():

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

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

    

    i = 1

    pas = [i]

    pas_set = set(pas)

    k = 1

    while k <= K:

        if A[i] in pas_set:

            rps = pas.index(A[i])

            ans = A[i]

            break

        pas.append(A[i])

        pas_set.add(A[i])

        ans = A[i]

        i = A[i]

        k += 1



    if k >= K:

        print(ans)

    else:

        rpnum = (K-rps)%(k-rps)

        print((pas[rps+rpnum]))



main()
import numpy as np


def main():
    N, K = list(map(int, input().split()))
    A = [0]
    A += list(map(int, input().split()))
    A = np.array(A)
    i = 1
    pas = np.zeros(N)
    pas[0] = i
    k = 1
    pass_set = set(pas)
    while k <= K:
        if A[i] in pass_set:
            rps = np.where(pas == (A[i]))[0]
            ans = A[i]
            break
        pas[k] = A[i]
        pass_set.add(A[i])
        ans = A[i]
        i = A[i]
        k += 1
    if k >= K:
        print(ans)
    else:
        rpnum = (K - rps[0]) % (k - rps)
        print((int(pas[rps[0] + rpnum])))


main()

def main():
    N, K = list(map(int, input().split()))
    A = [0] + list(map(int, input().split()))
    i = 1
    pas = [i]
    pas_set = set(pas)
    k = 1
    while k <= K:
        if A[i] in pas_set:
            rps = pas.index(A[i])
            ans = A[i]
            break
        pas.append(A[i])
        pas_set.add(A[i])
        ans = A[i]
        i = A[i]
        k += 1
    if k >= K:
        print(ans)
    else:
        rpnum = (K - rps) % (k - rps)
        print((pas[rps + rpnum]))


main()

-import numpy as np - - -    A = [0] -    A += list(map(int, input().split())) -    A = np.array(A) +    A = [0] + list(map(int, input().split())) -    pas = np.zeros(N) -    pas[0] = i +    pas = [i] +    pas_set = set(pas) -    pass_set = set(pas) -        if A[i] in pass_set: -            rps = np.where(pas == (A[i]))[0] +        if A[i] in pas_set: +            rps = pas.index(A[i]) -        pas[k] = A[i] -        pass_set.add(A[i]) +        pas.append(A[i]) +        pas_set.add(A[i]) -        rpnum = (K - rps[0]) % (k - rps) -        print((int(pas[rps[0] + rpnum]))) +        rpnum = (K - rps) % (k - rps) +        print((pas[rps + rpnum]))