Buggy python submission (verdict: Runtime Error):
'''
Fuad Ashraful Mehmet
University of Asia Pacific,Bangladesh
Date: 7th May 2020
'''


n,k=[int(x) for x in input().split()]
vis=[-1 for i in range(n+4)]
node=0
a=[int(x) for x in input().split()]
a=[0]+a
#print(a)

def dfs(u,l,turn):
    if turn<=0:
        print(u)
        return -1
    if vis[u]!=-1:
        global node
        node=u
        #print("node "+str(node))
        return l-vis[node]
    vis[u]=l
    return dfs(a[u],l+1,turn-1)

diff=dfs(1,0,k)
if diff==-1:
    exit()
else:

    lo=1
    hi=10**25
    cost=vis[node]

    while lo<=hi:
        mid=(lo+hi)//2
        temp=mid*diff
        #print(lo,hi)
        if cost+temp<=k:
            lo=mid+1
        else:
            hi=mid-1


    t=hi*diff+cost
    #print("Node "+str(node))
    def dfs2(u,turn):
        if turn<=0:
            print(u)
            return
        
        dfs2(a[u],turn-1)

    dfs2(node,k-t)


Fixed submission:
'''
Fuad Ashraful Mehmet
University of Asia Pacific,Bangladesh
Date: 7th May 2020
'''

n,k=map(int,input().split())
a=list(map(int,input().split()))
a=[0]+a
vis=[-1]*(n+5)


turn=k
now=1
c=0
while vis[now]==-1:

    if turn<=0:
        print(now)
        exit()
    vis[now]=c
    c+=1
    now=a[now]
    turn=turn-1

diff =c-vis[now]

lo=1
hi=10**25
cost=vis[now]
while lo<=hi:

    mid=(lo+hi)//2
    t=mid*diff
    if t+cost<=k:
       lo=mid+1
    else:
        hi=mid-1

t=hi*diff+cost


rem=k-t

while rem>0:
    now=a[now]
    rem-=1

print(now)

Buggy python submission (verdict: Runtime Error):
'''
Fuad Ashraful Mehmet
University of Asia Pacific,Bangladesh
Date: 7th May 2020
'''


n,k=[int(x) for x in input().split()]
vis=[-1 for i in range(n+4)]
node=0
a=[int(x) for x in input().split()]
a=[0]+a
#print(a)

def dfs(u,l,turn):
    if turn<=0:
        print(u)
        return -1
    if vis[u]!=-1:
        global node
        node=u
        #print("node "+str(node))
        return l-vis[node]
    vis[u]=l
    return dfs(a[u],l+1,turn-1)

diff=dfs(1,0,k)
if diff==-1:
    exit()
lo=1
hi=10**25
cost=vis[node]

while lo<=hi:
    mid=(lo+hi)//2
    temp=mid*diff
    #print(lo,hi)
    if cost+temp<=k:
        lo=mid+1
    else:
        hi=mid-1


t=hi*diff+cost

#print(k-t)

def dfs2(u,turn):
    if turn<=0:
        print(u)
        return
    
    dfs2(a[u],turn-1)

dfs2(node,k-t)


Fixed submission:
'''
Fuad Ashraful Mehmet
University of Asia Pacific,Bangladesh
Date: 7th May 2020
'''

n,k=map(int,input().split())
a=list(map(int,input().split()))
a=[0]+a
vis=[-1]*(n+5)


turn=k
now=1
c=0
while vis[now]==-1:

    if turn<=0:
        print(now)
        exit()
    vis[now]=c
    c+=1
    now=a[now]
    turn=turn-1

diff =c-vis[now]

lo=1
hi=10**25
cost=vis[now]
while lo<=hi:

    mid=(lo+hi)//2
    t=mid*diff
    if t+cost<=k:
       lo=mid+1
    else:
        hi=mid-1

t=hi*diff+cost


rem=k-t

while rem>0:
    now=a[now]
    rem-=1

print(now)

Buggy python submission (verdict: Runtime Error):
'''
Fuad Ashraful Mehmet
University of Asia Pacific,Bangladesh
Date: 7th May 2020
'''


n,k=[int(x) for x in input().split()]
vis=[-1 for i in range(n+4)]
node=0
a=[int(x) for x in input().split()]
a=[0]+a
#print(a)

def dfs(u,l,turn):
    if turn<=0:
        print(u)
        return -1
    if vis[u]!=-1:
        global node
        node=u
        #print("node "+str(node))
        return l-vis[node]
    vis[u]=l
    return dfs(a[u],l+1,turn-1)

diff=dfs(1,0,k)
lo=1
hi=10**24
cost=vis[node]

while lo<=hi:
    mid=(lo+hi)//2
    temp=mid*diff
    #print(lo,hi)
    if cost+temp<=k:
        lo=mid+1
    else:
        hi=mid-1


t=hi*diff+cost

#print(k-t)

def dfs2(u,turn):
    if turn<=0:
        print(u)
        return
    
    dfs2(a[u],turn-1)

dfs2(node,k-t)


Fixed submission:
'''
Fuad Ashraful Mehmet
University of Asia Pacific,Bangladesh
Date: 7th May 2020
'''

n,k=map(int,input().split())
a=list(map(int,input().split()))
a=[0]+a
vis=[-1]*(n+5)


turn=k
now=1
c=0
while vis[now]==-1:

    if turn<=0:
        print(now)
        exit()
    vis[now]=c
    c+=1
    now=a[now]
    turn=turn-1

diff =c-vis[now]

lo=1
hi=10**25
cost=vis[now]
while lo<=hi:

    mid=(lo+hi)//2
    t=mid*diff
    if t+cost<=k:
       lo=mid+1
    else:
        hi=mid-1

t=hi*diff+cost


rem=k-t

while rem>0:
    now=a[now]
    rem-=1

print(now)