import sys



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

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

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



    tree = [[] for _ in range(n)]

    for idx, a in enumerate(A):

        tree[idx].append(a - 1)



    start = []

    depth = [0 for _ in range(n)]



    def dfs(v, p, d, cnt):

        depth[v] = d

        for u in tree[v]:

            if visited[u]:

                start.append([u + 1, depth[u], cnt + 1])

                return

            else:

                visited[u] = True

                dfs(u, v, d + 1, cnt + 1)

        return



    visited = [False for _ in range(n)]

    visited[0] = True

    dfs(0, -1, 0, 0)



    if k <= start[0][1]:

        print((depth.index(k) + 1))

    else:

        cnt = (k - start[0][1]) % (start[0][2] - start[0][1])

        res = start[0][1] + cnt

        print((depth.index(res) + 1))





if __name__ == '__main__':

    resolve()

import sys



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

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

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



    tree = [[] for _ in range(n)]

    for idx, a in enumerate(A):

        tree[idx].append(a - 1)



    def dfs(pre, dist):

        depth[pre] = dist

        for to in tree[pre]:

            if depth[to] != f_inf:

                cycle.append([depth[to], depth[pre] + 1])

                return

            else:

                dfs(to, dist + 1)



    cycle = []

    depth = [f_inf for _ in range(n)]

    dfs(0, 0)



    cycle_start = cycle[0][0]

    cycle_end = cycle[0][1]

    if k <= cycle_start:

        print((depth.index(k) + 1))

    else:

        remainder = (k - cycle_start) % (cycle_end - cycle_start)

        res = cycle_start + remainder

        print((depth.index(res) + 1))





if __name__ == '__main__':

    resolve()

import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n, k = list(map(int, input().split()))
    A = list(map(int, input().split()))
    tree = [[] for _ in range(n)]
    for idx, a in enumerate(A):
        tree[idx].append(a - 1)
    start = []
    depth = [0 for _ in range(n)]

    def dfs(v, p, d, cnt):
        depth[v] = d
        for u in tree[v]:
            if visited[u]:
                start.append([u + 1, depth[u], cnt + 1])
                return
            else:
                visited[u] = True
                dfs(u, v, d + 1, cnt + 1)
        return

    visited = [False for _ in range(n)]
    visited[0] = True
    dfs(0, -1, 0, 0)
    if k <= start[0][1]:
        print((depth.index(k) + 1))
    else:
        cnt = (k - start[0][1]) % (start[0][2] - start[0][1])
        res = start[0][1] + cnt
        print((depth.index(res) + 1))


if __name__ == "__main__":
    resolve()

import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n, k = list(map(int, input().split()))
    A = list(map(int, input().split()))
    tree = [[] for _ in range(n)]
    for idx, a in enumerate(A):
        tree[idx].append(a - 1)

    def dfs(pre, dist):
        depth[pre] = dist
        for to in tree[pre]:
            if depth[to] != f_inf:
                cycle.append([depth[to], depth[pre] + 1])
                return
            else:
                dfs(to, dist + 1)

    cycle = []
    depth = [f_inf for _ in range(n)]
    dfs(0, 0)
    cycle_start = cycle[0][0]
    cycle_end = cycle[0][1]
    if k <= cycle_start:
        print((depth.index(k) + 1))
    else:
        remainder = (k - cycle_start) % (cycle_end - cycle_start)
        res = cycle_start + remainder
        print((depth.index(res) + 1))


if __name__ == "__main__":
    resolve()

-    start = [] -    depth = [0 for _ in range(n)] -    def dfs(v, p, d, cnt): -        depth[v] = d -        for u in tree[v]: -            if visited[u]: -                start.append([u + 1, depth[u], cnt + 1]) +    def dfs(pre, dist): +        depth[pre] = dist +        for to in tree[pre]: +            if depth[to] != f_inf: +                cycle.append([depth[to], depth[pre] + 1]) -                visited[u] = True -                dfs(u, v, d + 1, cnt + 1) -        return +                dfs(to, dist + 1) -    visited = [False for _ in range(n)] -    visited[0] = True -    dfs(0, -1, 0, 0) -    if k <= start[0][1]: +    cycle = [] +    depth = [f_inf for _ in range(n)] +    dfs(0, 0) +    cycle_start = cycle[0][0] +    cycle_end = cycle[0][1] +    if k <= cycle_start: -        cnt = (k - start[0][1]) % (start[0][2] - start[0][1]) -        res = start[0][1] + cnt +        remainder = (k - cycle_start) % (cycle_end - cycle_start) +        res = cycle_start + remainder