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

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



now = 1

visited = []

visited_set = set()



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

    visited.append(now)

    visited_set.add(now)

    now = A[now]

    if now in visited_set:

        loop_start = visited.index(now)

        loop_length = i - loop_start

        break



if K >= loop_start:

    print((visited[loop_start + (K - loop_start) % loop_length]))

else:

    print((visited[K]))

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

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



now = 1

visited = []

visited_set = set()

flag = False



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

    visited.append(now)

    visited_set.add(now)

    now = A[now]

    if now in visited_set:

        loop_start = visited.index(now)

        loop_length = i - loop_start

        flag = True

        break

else:

    print(now)



if flag:

    print((visited[loop_start + (K - loop_start) % loop_length]))

N, K = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))
now = 1
visited = []
visited_set = set()
for i in range(1, N + 1):
    visited.append(now)
    visited_set.add(now)
    now = A[now]
    if now in visited_set:
        loop_start = visited.index(now)
        loop_length = i - loop_start
        break
if K >= loop_start:
    print((visited[loop_start + (K - loop_start) % loop_length]))
else:
    print((visited[K]))

N, K = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))
now = 1
visited = []
visited_set = set()
flag = False
for i in range(1, K + 1):
    visited.append(now)
    visited_set.add(now)
    now = A[now]
    if now in visited_set:
        loop_start = visited.index(now)
        loop_length = i - loop_start
        flag = True
        break
else:
    print(now)
if flag:
    print((visited[loop_start + (K - loop_start) % loop_length]))

-for i in range(1, N + 1): +flag = False +for i in range(1, K + 1): +        flag = True -if K >= loop_start: +else: +    print(now) +if flag: -else: -    print((visited[K]))