def main():

    N, K, *A = list(map(int, open(0).read().split()))

    A = [0] + A

    cur = 1

    visited = [-1] * (N + 1)

    visited[cur] = 0

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

        next = A[cur]

        if cur == next:

            print(next)

            return

        elif (j := visited[next]) != -1:

            print((visited.index((K - j) % (i - j) + j)))

            break

        else:

            visited[next] = visited[cur] + 1

            cur = next

    else:

        print(next)

        return





if __name__ == "__main__":

    main()

def main():

    N, K, *A = list(map(int, open(0).read().split()))

    A = [0] + A

    cur_pos = 1

    last_visit = [-1] * (N + 1)

    last_visit[cur_pos] = 0

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

        nxt_pos = A[cur_pos]

        if cur_pos == nxt_pos:

            print(nxt_pos)

            return 

        elif (j := last_visit[nxt_pos]) != -1:

            print((last_visit.index((K - j) % (i - j) + j)))

            return 

        else:

            last_visit[nxt_pos] = last_visit[cur_pos] + 1

            cur_pos = nxt_pos

    print(cur_pos)





if __name__ == "__main__":

    main()

def main():
    N, K, *A = list(map(int, open(0).read().split()))
    A = [0] + A
    cur = 1
    visited = [-1] * (N + 1)
    visited[cur] = 0
    for i in range(1, K + 1):
        next = A[cur]
        if cur == next:
            print(next)
            return
        elif (j := visited[next]) != -1:
            print((visited.index((K - j) % (i - j) + j)))
            break
        else:
            visited[next] = visited[cur] + 1
            cur = next
    else:
        print(next)
        return


if __name__ == "__main__":
    main()

def main():
    N, K, *A = list(map(int, open(0).read().split()))
    A = [0] + A
    cur_pos = 1
    last_visit = [-1] * (N + 1)
    last_visit[cur_pos] = 0
    for i in range(1, K + 1):
        nxt_pos = A[cur_pos]
        if cur_pos == nxt_pos:
            print(nxt_pos)
            return
        elif (j := last_visit[nxt_pos]) != -1:
            print((last_visit.index((K - j) % (i - j) + j)))
            return
        else:
            last_visit[nxt_pos] = last_visit[cur_pos] + 1
            cur_pos = nxt_pos
    print(cur_pos)


if __name__ == "__main__":
    main()

-    cur = 1 -    visited = [-1] * (N + 1) -    visited[cur] = 0 +    cur_pos = 1 +    last_visit = [-1] * (N + 1) +    last_visit[cur_pos] = 0 -        next = A[cur] -        if cur == next: -            print(next) +        nxt_pos = A[cur_pos] +        if cur_pos == nxt_pos: +            print(nxt_pos) -        elif (j := visited[next]) != -1: -            print((visited.index((K - j) % (i - j) + j))) -            break +        elif (j := last_visit[nxt_pos]) != -1: +            print((last_visit.index((K - j) % (i - j) + j))) +            return -            visited[next] = visited[cur] + 1 -            cur = next -    else: -        print(next) -        return +            last_visit[nxt_pos] = last_visit[cur_pos] + 1 +            cur_pos = nxt_pos +    print(cur_pos)