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

a=[0]+list(map(int,input().split()))



MAX_N=2*10**5

b=[1]

visited=[-1]*(n+10)

for i in range(1,2*MAX_N+1):

    nxt=a[b[-1]]

    b.append(nxt)

        

if k<=n:

    print((b[k]))

    exit()

# print(b)  

for i,bi in enumerate(b):

    if visited[bi]==-1:

        visited[bi]=i

    else:

        m=i-visited[bi]

        l=visited[bi]

        break

k=k%m



while k<n:

    k+=m

print((b[k]))

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



now=1

if k<=n:

  for i in range(k):

    now=a[now-1]

  print(now)

  exit()

# 絶対ループする

visited=[False]*n

visited[now-1]=-1

for i in range(4*10**5):

  now=a[now-1]

  if visited[now-1]==False:

    visited[now-1]=i

  else:

    c,d=visited[now-1],i

    break



k=(k-c)%(d-c)+c

while k<n:

  k+=(d-c)

now=1

for i in range(k):

  now=a[now-1]

print(now)
n, k = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
MAX_N = 2 * 10**5
b = [1]
visited = [-1] * (n + 10)
for i in range(1, 2 * MAX_N + 1):
    nxt = a[b[-1]]
    b.append(nxt)
if k <= n:
    print((b[k]))
    exit()
# print(b)
for i, bi in enumerate(b):
    if visited[bi] == -1:
        visited[bi] = i
    else:
        m = i - visited[bi]
        l = visited[bi]
        break
k = k % m
while k < n:
    k += m
print((b[k]))

n, k, *a = list(map(int, open(0).read().split()))
now = 1
if k <= n:
    for i in range(k):
        now = a[now - 1]
    print(now)
    exit()
# 絶対ループする
visited = [False] * n
visited[now - 1] = -1
for i in range(4 * 10**5):
    now = a[now - 1]
    if visited[now - 1] == False:
        visited[now - 1] = i
    else:
        c, d = visited[now - 1], i
        break
k = (k - c) % (d - c) + c
while k < n:
    k += d - c
now = 1
for i in range(k):
    now = a[now - 1]
print(now)

-n, k = list(map(int, input().split())) -a = [0] + list(map(int, input().split())) -MAX_N = 2 * 10**5 -b = [1] -visited = [-1] * (n + 10) -for i in range(1, 2 * MAX_N + 1): -    nxt = a[b[-1]] -    b.append(nxt) +n, k, *a = list(map(int, open(0).read().split())) +now = 1 -    print((b[k])) +    for i in range(k): +        now = a[now - 1] +    print(now) -# print(b) -for i, bi in enumerate(b): -    if visited[bi] == -1: -        visited[bi] = i +# 絶対ループする +visited = [False] * n +visited[now - 1] = -1 +for i in range(4 * 10**5): +    now = a[now - 1] +    if visited[now - 1] == False: +        visited[now - 1] = i -        m = i - visited[bi] -        l = visited[bi] +        c, d = visited[now - 1], i -k = k % m +k = (k - c) % (d - c) + c -    k += m -print((b[k])) +    k += d - c +now = 1 +for i in range(k): +    now = a[now - 1] +print(now)