import sys

sys.setrecursionlimit(2147483647)

INF = 1 << 60

MOD = 10**9 + 7 # 998244353

input = lambda:sys.stdin.readline().rstrip()

def resolve():

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

    A = list([int(x) - 1 for x in input().split()])



    nexts = []

    nexts.append(A)

    for _ in range(61):

        next = nexts[-1]

        nnext = [None] * n

        for i in range(n):

            nnext[i] = next[next[i]]

        nexts.append(nnext)



    now = 0

    for d in range(61):

        if (k >> d) & 1:

            now = nexts[d][now]



    print((now + 1))

resolve()
import sys

INF = 1 << 60

MOD = 10**9 + 7 # 998244353

sys.setrecursionlimit(2147483647)

input = lambda:sys.stdin.readline().rstrip()

def resolve():

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

    b = list([int(x) - 1 for x in input().split()])



    now = 0

    while k:

        if k & 1: now = b[now]

        b = [b[b[i]] for i in range(n)]

        k >>= 1

    print((now + 1))

resolve()
import sys

sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7  # 998244353
input = lambda: sys.stdin.readline().rstrip()


def resolve():
    n, k = list(map(int, input().split()))
    A = list([int(x) - 1 for x in input().split()])
    nexts = []
    nexts.append(A)
    for _ in range(61):
        next = nexts[-1]
        nnext = [None] * n
        for i in range(n):
            nnext[i] = next[next[i]]
        nexts.append(nnext)
    now = 0
    for d in range(61):
        if (k >> d) & 1:
            now = nexts[d][now]
    print((now + 1))


resolve()

import sys

INF = 1 << 60
MOD = 10**9 + 7  # 998244353
sys.setrecursionlimit(2147483647)
input = lambda: sys.stdin.readline().rstrip()


def resolve():
    n, k = list(map(int, input().split()))
    b = list([int(x) - 1 for x in input().split()])
    now = 0
    while k:
        if k & 1:
            now = b[now]
        b = [b[b[i]] for i in range(n)]
        k >>= 1
    print((now + 1))


resolve()

-sys.setrecursionlimit(2147483647) +sys.setrecursionlimit(2147483647) -    A = list([int(x) - 1 for x in input().split()]) -    nexts = [] -    nexts.append(A) -    for _ in range(61): -        next = nexts[-1] -        nnext = [None] * n -        for i in range(n): -            nnext[i] = next[next[i]] -        nexts.append(nnext) +    b = list([int(x) - 1 for x in input().split()]) -    for d in range(61): -        if (k >> d) & 1: -            now = nexts[d][now] +    while k: +        if k & 1: +            now = b[now] +        b = [b[b[i]] for i in range(n)] +        k >>= 1