def main():

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

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

    city_l = [1]

    city_s = set([1])

    loop_city_l = []

    curr_city = 1

    cnt = 0

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

        next_c = al[curr_city-1]

        if next_c in city_s:

            cnt = i

            first_city = city_l.index(next_c)

            loop_city_l = city_l[first_city:]

            break

        else:

            city_s.add(next_c)

            city_l.append(next_c)

        curr_city = next_c

    else:

        print(curr_city)

        return



    # print(loop_city_l)

    remained = k-cnt

    last_pos = remained%len(loop_city_l)

    print((loop_city_l[last_pos]))



if __name__ == "__main__":

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

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



cnt = 0

cl = [-1]*(n+1)

cll = [1]

curr = 1

for i in range(min(n,k)):

    # print(curr)

    next_c = al[curr-1]

    if cl[next_c] != -1:

        # loop_start = (i+1)

        loop_start = cl[next_c]

        rem = k - (i+1)

        break

    else:

        cl[next_c] = i + 1

        cll.append(next_c)

    curr = next_c



else:

    print(curr)

    exit()



# print(rem)

loop_c = cll[loop_start:]

# print(loop_c)

last_ind = rem%len(loop_c)

ans = loop_c[last_ind]

print(ans)
def main():
    n, k = list(map(int, input().split()))
    al = list(map(int, input().split()))
    city_l = [1]
    city_s = set([1])
    loop_city_l = []
    curr_city = 1
    cnt = 0
    for i in range(1, k + 1):
        next_c = al[curr_city - 1]
        if next_c in city_s:
            cnt = i
            first_city = city_l.index(next_c)
            loop_city_l = city_l[first_city:]
            break
        else:
            city_s.add(next_c)
            city_l.append(next_c)
        curr_city = next_c
    else:
        print(curr_city)
        return
    # print(loop_city_l)
    remained = k - cnt
    last_pos = remained % len(loop_city_l)
    print((loop_city_l[last_pos]))


if __name__ == "__main__":
    main()

n, k = list(map(int, input().split()))
al = list(map(int, input().split()))
cnt = 0
cl = [-1] * (n + 1)
cll = [1]
curr = 1
for i in range(min(n, k)):
    # print(curr)
    next_c = al[curr - 1]
    if cl[next_c] != -1:
        # loop_start = (i+1)
        loop_start = cl[next_c]
        rem = k - (i + 1)
        break
    else:
        cl[next_c] = i + 1
        cll.append(next_c)
    curr = next_c
else:
    print(curr)
    exit()
# print(rem)
loop_c = cll[loop_start:]
# print(loop_c)
last_ind = rem % len(loop_c)
ans = loop_c[last_ind]
print(ans)

-def main(): -    n, k = list(map(int, input().split())) -    al = list(map(int, input().split())) -    city_l = [1] -    city_s = set([1]) -    loop_city_l = [] -    curr_city = 1 -    cnt = 0 -    for i in range(1, k + 1): -        next_c = al[curr_city - 1] -        if next_c in city_s: -            cnt = i -            first_city = city_l.index(next_c) -            loop_city_l = city_l[first_city:] -            break -        else: -            city_s.add(next_c) -            city_l.append(next_c) -        curr_city = next_c +n, k = list(map(int, input().split())) +al = list(map(int, input().split())) +cnt = 0 +cl = [-1] * (n + 1) +cll = [1] +curr = 1 +for i in range(min(n, k)): +    # print(curr) +    next_c = al[curr - 1] +    if cl[next_c] != -1: +        # loop_start = (i+1) +        loop_start = cl[next_c] +        rem = k - (i + 1) +        break -        print(curr_city) -        return -    # print(loop_city_l) -    remained = k - cnt -    last_pos = remained % len(loop_city_l) -    print((loop_city_l[last_pos])) - - -if __name__ == "__main__": -    main() +        cl[next_c] = i + 1 +        cll.append(next_c) +    curr = next_c +else: +    print(curr) +    exit() +# print(rem) +loop_c = cll[loop_start:] +# print(loop_c) +last_ind = rem % len(loop_c) +ans = loop_c[last_ind] +print(ans)