import sys

import numpy as np

from collections import defaultdict







#input = sys.stdin.readline



def main():

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

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

    A = [0] +A  #transporter

    visited = [0] * (N+1)

    town = 1

    cycle = 0

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

        town = A[town]

        if visited[town] ==0:

            visited[town] = i

        else:

            cycle = i - visited[town]

            place = (K - visited[town]) % cycle + visited[town]

            print((visited.index(place)))

            exit()

    print(town)









if __name__ == "__main__":

    main()




#input = sys.stdin.readline



def main():

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

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

    A = [0] +A  #transporter

    visited = [0] * (N+1)

    town = 1

    cycle = 0

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

        town = A[town]

        if visited[town] ==0:

            visited[town] = i

        else:

            cycle = i - visited[town]

            place = (K - visited[town]) % cycle + visited[town]

            print((visited.index(place)))

            exit()

    print(town)









if __name__ == "__main__":

    main()
import sys
import numpy as np
from collections import defaultdict

# input = sys.stdin.readline
def main():
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    A = [0] + A  # transporter
    visited = [0] * (N + 1)
    town = 1
    cycle = 0
    for i in range(1, K + 1):
        town = A[town]
        if visited[town] == 0:
            visited[town] = i
        else:
            cycle = i - visited[town]
            place = (K - visited[town]) % cycle + visited[town]
            print((visited.index(place)))
            exit()
    print(town)


if __name__ == "__main__":
    main()

# input = sys.stdin.readline
def main():
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    A = [0] + A  # transporter
    visited = [0] * (N + 1)
    town = 1
    cycle = 0
    for i in range(1, K + 1):
        town = A[town]
        if visited[town] == 0:
            visited[town] = i
        else:
            cycle = i - visited[town]
            place = (K - visited[town]) % cycle + visited[town]
            print((visited.index(place)))
            exit()
    print(town)


if __name__ == "__main__":
    main()

-import sys -import numpy as np -from collections import defaultdict -