def d_teleporter():

    N, K = [int(i) for i in input().split()]

    A = [int(i) - 1 for i in input().split()]  # 0-origin



    from collections import defaultdict

    visit = [0]

    visit_dict = defaultdict(list)

    visit_dict[0] = [0]

    current = 0

    is_found_first = False

    for i in range(N):

        current = A[current]

        if len(visit_dict[current]) == 1 and not is_found_first:

            count_to_loop = visit_dict[current][0]

            loop_length = i - visit_dict[current][0] + 1

            is_found_first = True

        visit.append(current)

        visit_dict[current].append(i + 1)



    if K <= N:

        return visit[K] + 1

    net_moving_time = ((K - count_to_loop) % loop_length) + count_to_loop

    # 上の visit に必要な分だけ付け足してもいいが，実行時間は変わらなかった

    current = 0

    for _ in range(net_moving_time):

        current = A[current]

    return current + 1



print((d_teleporter()))
def d_teleporter():

    N, K = [int(i) for i in input().split()]

    A = [int(i) - 1 for i in input().split()]  # 0-origin



    visit_list, visit_dict = list(), dict()

    current_city = 0

    for i in range(min(K, N)):  # N 回移動すればループはわかる

        current_city = A[current_city]

        if current_city in visit_dict:  # ループを検出した

            j = visit_list.index(current_city)  # ここからループ

            current_city = visit_list[j + (K - j - 1) % (i - j)]

            return current_city + 1

        else:

            visit_list.append(current_city)

            visit_dict[current_city] = current_city

    return current_city + 1



print((d_teleporter()))
def d_teleporter():
    N, K = [int(i) for i in input().split()]
    A = [int(i) - 1 for i in input().split()]  # 0-origin
    from collections import defaultdict

    visit = [0]
    visit_dict = defaultdict(list)
    visit_dict[0] = [0]
    current = 0
    is_found_first = False
    for i in range(N):
        current = A[current]
        if len(visit_dict[current]) == 1 and not is_found_first:
            count_to_loop = visit_dict[current][0]
            loop_length = i - visit_dict[current][0] + 1
            is_found_first = True
        visit.append(current)
        visit_dict[current].append(i + 1)
    if K <= N:
        return visit[K] + 1
    net_moving_time = ((K - count_to_loop) % loop_length) + count_to_loop
    # 上の visit に必要な分だけ付け足してもいいが，実行時間は変わらなかった
    current = 0
    for _ in range(net_moving_time):
        current = A[current]
    return current + 1


print((d_teleporter()))

def d_teleporter():
    N, K = [int(i) for i in input().split()]
    A = [int(i) - 1 for i in input().split()]  # 0-origin
    visit_list, visit_dict = list(), dict()
    current_city = 0
    for i in range(min(K, N)):  # N 回移動すればループはわかる
        current_city = A[current_city]
        if current_city in visit_dict:  # ループを検出した
            j = visit_list.index(current_city)  # ここからループ
            current_city = visit_list[j + (K - j - 1) % (i - j)]
            return current_city + 1
        else:
            visit_list.append(current_city)
            visit_dict[current_city] = current_city
    return current_city + 1


print((d_teleporter()))

-    from collections import defaultdict - -    visit = [0] -    visit_dict = defaultdict(list) -    visit_dict[0] = [0] -    current = 0 -    is_found_first = False -    for i in range(N): -        current = A[current] -        if len(visit_dict[current]) == 1 and not is_found_first: -            count_to_loop = visit_dict[current][0] -            loop_length = i - visit_dict[current][0] + 1 -            is_found_first = True -        visit.append(current) -        visit_dict[current].append(i + 1) -    if K <= N: -        return visit[K] + 1 -    net_moving_time = ((K - count_to_loop) % loop_length) + count_to_loop -    # 上の visit に必要な分だけ付け足してもいいが，実行時間は変わらなかった -    current = 0 -    for _ in range(net_moving_time): -        current = A[current] -    return current + 1 +    visit_list, visit_dict = list(), dict() +    current_city = 0 +    for i in range(min(K, N)):  # N 回移動すればループはわかる +        current_city = A[current_city] +        if current_city in visit_dict:  # ループを検出した +            j = visit_list.index(current_city)  # ここからループ +            current_city = visit_list[j + (K - j - 1) % (i - j)] +            return current_city + 1 +        else: +            visit_list.append(current_city) +            visit_dict[current_city] = current_city +    return current_city + 1