n,k,*a=list(map(int,open(0).read().split()))

v=[0]+[-1]*n

p=0

for i in range(n):

  t=a[p]-1

  if v[t]>=0: l,r=v[t],i+1; break

  v[t]=i+1; p=t

print((v.index(min(k,l+(k-l)%(r-l)))+1))
n,k,*a=list(map(int,open(0).read().split()))

v=[0]+[-1]*n

t=a[0]-1

c=1

while v[t]<0:

  v[t]=c

  t=a[t]-1

  c+=1

l=v[t]

c-=l

print((v.index(min(k,l+(k-l)%c))+1))
n, k, *a = list(map(int, open(0).read().split()))
v = [0] + [-1] * n
p = 0
for i in range(n):
    t = a[p] - 1
    if v[t] >= 0:
        l, r = v[t], i + 1
        break
    v[t] = i + 1
    p = t
print((v.index(min(k, l + (k - l) % (r - l))) + 1))

n, k, *a = list(map(int, open(0).read().split()))
v = [0] + [-1] * n
t = a[0] - 1
c = 1
while v[t] < 0:
    v[t] = c
    t = a[t] - 1
    c += 1
l = v[t]
c -= l
print((v.index(min(k, l + (k - l) % c)) + 1))

-p = 0 -for i in range(n): -    t = a[p] - 1 -    if v[t] >= 0: -        l, r = v[t], i + 1 -        break -    v[t] = i + 1 -    p = t -print((v.index(min(k, l + (k - l) % (r - l))) + 1)) +t = a[0] - 1 +c = 1 +while v[t] < 0: +    v[t] = c +    t = a[t] - 1 +    c += 1 +l = v[t] +c -= l +print((v.index(min(k, l + (k - l) % c)) + 1))