import sys

readline = sys.stdin.readline



def main():

    N, K = list(map(int, readline().rstrip().split()))

    A = list(map(int, readline().rstrip().split()))

    d = {i+1: a for i, a in enumerate(A)}

    if K <= N:

        pre = 1

        for _ in range(K):

            pre = d[pre]

        print(pre)

        return



    pre = 1

    visited = set([1])

    visited_l = [1]

    for i in range(N):

        pre = d[pre]

        if pre in visited:

            break

        visited.add(pre)

        visited_l.append(pre)

    

    loop_start = visited_l.index(pre)

    loop = i - loop_start + 1



    num_loop = (K - loop_start) // loop

    now = loop_start + num_loop * loop

    for i in range(now+1, K+1):

        pre = d[pre]

    

    print(pre)



if __name__ == '__main__':

    main()
import sys

readline = sys.stdin.readline



def main():

    N, K = list(map(int, readline().rstrip().split()))

    d = list(map(int, readline().rstrip().split()))

    # d = {i+1: a for i, a in enumerate(A)}

    if K <= N:

        pre = 1

        for _ in range(K):

            pre = d[pre-1]

        print(pre)

        return



    pre = 1

    visited = set([1])

    visited_l = [1]

    for i in range(N):

        pre = d[pre-1]

        if pre in visited:

            break

        visited.add(pre)

        visited_l.append(pre)

    

    loop_start = visited_l.index(pre)

    loop = i - loop_start + 1



    num_loop = (K - loop_start) // loop

    now = loop_start + num_loop * loop

    for i in range(now+1, K+1):

        pre = d[pre-1]

    

    print(pre)



if __name__ == '__main__':

    main()
import sys

readline = sys.stdin.readline


def main():
    N, K = list(map(int, readline().rstrip().split()))
    A = list(map(int, readline().rstrip().split()))
    d = {i + 1: a for i, a in enumerate(A)}
    if K <= N:
        pre = 1
        for _ in range(K):
            pre = d[pre]
        print(pre)
        return
    pre = 1
    visited = set([1])
    visited_l = [1]
    for i in range(N):
        pre = d[pre]
        if pre in visited:
            break
        visited.add(pre)
        visited_l.append(pre)
    loop_start = visited_l.index(pre)
    loop = i - loop_start + 1
    num_loop = (K - loop_start) // loop
    now = loop_start + num_loop * loop
    for i in range(now + 1, K + 1):
        pre = d[pre]
    print(pre)


if __name__ == "__main__":
    main()

import sys

readline = sys.stdin.readline


def main():
    N, K = list(map(int, readline().rstrip().split()))
    d = list(map(int, readline().rstrip().split()))
    # d = {i+1: a for i, a in enumerate(A)}
    if K <= N:
        pre = 1
        for _ in range(K):
            pre = d[pre - 1]
        print(pre)
        return
    pre = 1
    visited = set([1])
    visited_l = [1]
    for i in range(N):
        pre = d[pre - 1]
        if pre in visited:
            break
        visited.add(pre)
        visited_l.append(pre)
    loop_start = visited_l.index(pre)
    loop = i - loop_start + 1
    num_loop = (K - loop_start) // loop
    now = loop_start + num_loop * loop
    for i in range(now + 1, K + 1):
        pre = d[pre - 1]
    print(pre)


if __name__ == "__main__":
    main()

-    A = list(map(int, readline().rstrip().split())) -    d = {i + 1: a for i, a in enumerate(A)} +    d = list(map(int, readline().rstrip().split())) +    # d = {i+1: a for i, a in enumerate(A)} -            pre = d[pre] +            pre = d[pre - 1] -        pre = d[pre] +        pre = d[pre - 1] -        pre = d[pre] +        pre = d[pre - 1]