import sys

input = sys.stdin.readline



class Doubling:

    def __init__(self, A, K_max, decrement=True):

        """

        :param A: リスト。i から A[i] へと移動する

        :param K_max: K_max = 2**(k_max) まで参照する可能性がある

        :param decrement: True = A の要素の decrement が必要

        """

        self.k_max = K_max.bit_length()

        self.n = len(A)

        self.decrement = decrement

        self.doubling = [[-1] * self.n for _ in range(self.k_max)]

        for i, a in enumerate(A):

            self.doubling[0][i] = a - self.decrement



        for i in range(1, self.k_max):

            for j in range(self.n):

                if self.doubling[i - 1][j] != -1:

                    self.doubling[i][j] = self.doubling[i - 1][self.doubling[i - 1][j]]



    def apply(self, start, K):

        """

        :param start: スタート地点

        :param K: K回進む

        :return:

        """

        i = start - self.decrement

        for k in range(K.bit_length()):

            m = 1 << k

            if m & K:

                i = self.doubling[k][i]

            if i is None:

                break

        return i + self.decrement





######################################################################################





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

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

doubling = Doubling(A, 10**18 + 1, decrement=True)

print((doubling.apply(1, K)))
def cycle_getter(N, start):

    """

    :param N: 移動回数

    :param start:　初期条件

    :return front: cycleまでの要素のリスト

            cycle: cycle内の要素のリスト

            end: cycle後の余った部分の要素のリスト

            cnt: cycle回数

    """

    p = start

    front, cycle, end = [], [], []

    cnt = 0

    visit = {p:0}

    L, R = N, -1

    P = [p]

    for i in range(1,N):

        p = lift(p)

        if p in visit:

            """

            (L, R) = (サイクルに入るまでに移動した回数, サイクルの終端に着くまでに移動した回数)

            [6,2,3,4,0,1,2] ⇒ (L, R) = (1, 6)

            """

            L, R = visit[p], i

            period = R-L

            break

        visit[p] = i

        P.append(p)

    front = P[:L]

    if L != N:

        cycle, end = P[L:R], P[L:L+(N-L)%period]

        cnt = (N-L)//period

    return front, cycle, end, cnt



################################################################################





import sys

input = sys.stdin.readline



def lift(x): return A[x-1]



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

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

front, cycle, end, cnt = cycle_getter(K+1,1)

# print(front, cycle, end, cnt)

print(((front+cycle+end)[-1]))
import sys

input = sys.stdin.readline


class Doubling:
    def __init__(self, A, K_max, decrement=True):
        """
        :param A: リスト。i から A[i] へと移動する
        :param K_max: K_max = 2**(k_max) まで参照する可能性がある
        :param decrement: True = A の要素の decrement が必要
        """
        self.k_max = K_max.bit_length()
        self.n = len(A)
        self.decrement = decrement
        self.doubling = [[-1] * self.n for _ in range(self.k_max)]
        for i, a in enumerate(A):
            self.doubling[0][i] = a - self.decrement
        for i in range(1, self.k_max):
            for j in range(self.n):
                if self.doubling[i - 1][j] != -1:
                    self.doubling[i][j] = self.doubling[i - 1][self.doubling[i - 1][j]]

    def apply(self, start, K):
        """
        :param start: スタート地点
        :param K: K回進む
        :return:
        """
        i = start - self.decrement
        for k in range(K.bit_length()):
            m = 1 << k
            if m & K:
                i = self.doubling[k][i]
            if i is None:
                break
        return i + self.decrement


######################################################################################
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
doubling = Doubling(A, 10**18 + 1, decrement=True)
print((doubling.apply(1, K)))

def cycle_getter(N, start):
    """
    :param N: 移動回数
    :param start:　初期条件
    :return front: cycleまでの要素のリスト
            cycle: cycle内の要素のリスト
            end: cycle後の余った部分の要素のリスト
            cnt: cycle回数
    """
    p = start
    front, cycle, end = [], [], []
    cnt = 0
    visit = {p: 0}
    L, R = N, -1
    P = [p]
    for i in range(1, N):
        p = lift(p)
        if p in visit:
            """
            (L, R) = (サイクルに入るまでに移動した回数, サイクルの終端に着くまでに移動した回数)
            [6,2,3,4,0,1,2] ⇒ (L, R) = (1, 6)
            """
            L, R = visit[p], i
            period = R - L
            break
        visit[p] = i
        P.append(p)
    front = P[:L]
    if L != N:
        cycle, end = P[L:R], P[L : L + (N - L) % period]
        cnt = (N - L) // period
    return front, cycle, end, cnt


################################################################################
import sys

input = sys.stdin.readline


def lift(x):
    return A[x - 1]


N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
front, cycle, end, cnt = cycle_getter(K + 1, 1)
# print(front, cycle, end, cnt)
print(((front + cycle + end)[-1]))

+def cycle_getter(N, start): +    """ +    :param N: 移動回数 +    :param start:　初期条件 +    :return front: cycleまでの要素のリスト +            cycle: cycle内の要素のリスト +            end: cycle後の余った部分の要素のリスト +            cnt: cycle回数 +    """ +    p = start +    front, cycle, end = [], [], [] +    cnt = 0 +    visit = {p: 0} +    L, R = N, -1 +    P = [p] +    for i in range(1, N): +        p = lift(p) +        if p in visit: +            """ +            (L, R) = (サイクルに入るまでに移動した回数, サイクルの終端に着くまでに移動した回数) +            [6,2,3,4,0,1,2] ⇒ (L, R) = (1, 6) +            """ +            L, R = visit[p], i +            period = R - L +            break +        visit[p] = i +        P.append(p) +    front = P[:L] +    if L != N: +        cycle, end = P[L:R], P[L : L + (N - L) % period] +        cnt = (N - L) // period +    return front, cycle, end, cnt + + +################################################################################ -class Doubling: -    def __init__(self, A, K_max, decrement=True): -        """ -        :param A: リスト。i から A[i] へと移動する -        :param K_max: K_max = 2**(k_max) まで参照する可能性がある -        :param decrement: True = A の要素の decrement が必要 -        """ -        self.k_max = K_max.bit_length() -        self.n = len(A) -        self.decrement = decrement -        self.doubling = [[-1] * self.n for _ in range(self.k_max)] -        for i, a in enumerate(A): -            self.doubling[0][i] = a - self.decrement -        for i in range(1, self.k_max): -            for j in range(self.n): -                if self.doubling[i - 1][j] != -1: -                    self.doubling[i][j] = self.doubling[i - 1][self.doubling[i - 1][j]] - -    def apply(self, start, K): -        """ -        :param start: スタート地点 -        :param K: K回進む -        :return: -        """ -        i = start - self.decrement -        for k in range(K.bit_length()): -            m = 1 << k -            if m & K: -                i = self.doubling[k][i] -            if i is None: -                break -        return i + self.decrement +def lift(x): +    return A[x - 1] -###################################################################################### -doubling = Doubling(A, 10**18 + 1, decrement=True) -print((doubling.apply(1, K))) +front, cycle, end, cnt = cycle_getter(K + 1, 1) +# print(front, cycle, end, cnt) +print(((front + cycle + end)[-1]))