from collections import defaultdict





def inpl():

    return list(map(int, input().split()))





N, K = inpl()

aa = inpl()



s = 1



route = [s]

ed = set([s])



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

    s = aa[s - 1]

    if s in ed:

        Li = route.index(s)

        Ri = len(route)

        idx = Li + (K - Li) % (Ri - Li)

        print((route[idx]))

        break

    else:

        route.append(s)

        ed.add(s)

        continue

else:

    print(s)

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

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



visited= [1]

ed = set([1])

for i in range(K):

    next_town  = al[visited[i] - 1]

    if next_town in ed:

        loop_sta = visited.index((next_town)) #　visited_townsにおけるループ開始のインデックス

        loop_end = len(visited) #visited_townsにおけるループの終わりのインデックス

        loop_length = loop_end - loop_sta #繰り返すループの長さ

        amari = (K - loop_sta) % loop_length

        ans = visited[loop_sta + amari]

        print(ans)

        exit()

    else:

        visited.append(next_town)

        ed.add(next_town)

        continue



else:

    print((visited[-1]))



from collections import defaultdict


def inpl():
    return list(map(int, input().split()))


N, K = inpl()
aa = inpl()
s = 1
route = [s]
ed = set([s])
for i in range(1, K + 1):
    s = aa[s - 1]
    if s in ed:
        Li = route.index(s)
        Ri = len(route)
        idx = Li + (K - Li) % (Ri - Li)
        print((route[idx]))
        break
    else:
        route.append(s)
        ed.add(s)
        continue
else:
    print(s)

N, K = list(map(int, input().split()))
al = list(map(int, input().split()))
visited = [1]
ed = set([1])
for i in range(K):
    next_town = al[visited[i] - 1]
    if next_town in ed:
        loop_sta = visited.index((next_town))  # 　visited_townsにおけるループ開始のインデックス
        loop_end = len(visited)  # visited_townsにおけるループの終わりのインデックス
        loop_length = loop_end - loop_sta  # 繰り返すループの長さ
        amari = (K - loop_sta) % loop_length
        ans = visited[loop_sta + amari]
        print(ans)
        exit()
    else:
        visited.append(next_town)
        ed.add(next_town)
        continue
else:
    print((visited[-1]))

-from collections import defaultdict - - -def inpl(): -    return list(map(int, input().split())) - - -N, K = inpl() -aa = inpl() -s = 1 -route = [s] -ed = set([s]) -for i in range(1, K + 1): -    s = aa[s - 1] -    if s in ed: -        Li = route.index(s) -        Ri = len(route) -        idx = Li + (K - Li) % (Ri - Li) -        print((route[idx])) -        break +N, K = list(map(int, input().split())) +al = list(map(int, input().split())) +visited = [1] +ed = set([1]) +for i in range(K): +    next_town = al[visited[i] - 1] +    if next_town in ed: +        loop_sta = visited.index((next_town))  # 　visited_townsにおけるループ開始のインデックス +        loop_end = len(visited)  # visited_townsにおけるループの終わりのインデックス +        loop_length = loop_end - loop_sta  # 繰り返すループの長さ +        amari = (K - loop_sta) % loop_length +        ans = visited[loop_sta + amari] +        print(ans) +        exit() -        route.append(s) -        ed.add(s) +        visited.append(next_town) +        ed.add(next_town) -    print(s) +    print((visited[-1]))