def main():

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

    D = K.bit_length()

    to = [[0] * D for _ in range(N)]



    for i, a in enumerate(map(int, input().split())):

        to[i][0] = a - 1



    for j in range(D - 1):

        for i in range(N):

            to[i][j+1] = to[to[i][j]][j]



    v = 0

    for i in reversed(list(range(D))):

        if (K >> i) & 1:

            v = to[v][i]



    print((v + 1))





if __name__ == "__main__":

    main()
def doubling_numpy():

    import numpy as np

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

    D = K.bit_length()

    U = N + 1

    dbl = np.zeros((D, U), dtype=np.int64)

    dbl[0, 1:] = np.array(input().split(), dtype=np.int64)



    for d in range(D - 1):

        dbl[d+1] = dbl[d, dbl[d]]



    v = 1

    for i in reversed(list(range(D))):

        if K & (1 << i):

            v = dbl[i, v]

    print(v)





if __name__ == "__main__":

    doubling_numpy()
def main():
    N, K = list(map(int, input().split()))
    D = K.bit_length()
    to = [[0] * D for _ in range(N)]
    for i, a in enumerate(map(int, input().split())):
        to[i][0] = a - 1
    for j in range(D - 1):
        for i in range(N):
            to[i][j + 1] = to[to[i][j]][j]
    v = 0
    for i in reversed(list(range(D))):
        if (K >> i) & 1:
            v = to[v][i]
    print((v + 1))


if __name__ == "__main__":
    main()

def doubling_numpy():
    import numpy as np

    N, K = list(map(int, input().split()))
    D = K.bit_length()
    U = N + 1
    dbl = np.zeros((D, U), dtype=np.int64)
    dbl[0, 1:] = np.array(input().split(), dtype=np.int64)
    for d in range(D - 1):
        dbl[d + 1] = dbl[d, dbl[d]]
    v = 1
    for i in reversed(list(range(D))):
        if K & (1 << i):
            v = dbl[i, v]
    print(v)


if __name__ == "__main__":
    doubling_numpy()

-def main(): +def doubling_numpy(): +    import numpy as np + -    to = [[0] * D for _ in range(N)] -    for i, a in enumerate(map(int, input().split())): -        to[i][0] = a - 1 -    for j in range(D - 1): -        for i in range(N): -            to[i][j + 1] = to[to[i][j]][j] -    v = 0 +    U = N + 1 +    dbl = np.zeros((D, U), dtype=np.int64) +    dbl[0, 1:] = np.array(input().split(), dtype=np.int64) +    for d in range(D - 1): +        dbl[d + 1] = dbl[d, dbl[d]] +    v = 1 -        if (K >> i) & 1: -            v = to[v][i] -    print((v + 1)) +        if K & (1 << i): +            v = dbl[i, v] +    print(v) -    main() +    doubling_numpy()