def f():

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

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

    now=1



    for i in range(k.bit_length()):

        if k%2:now=l[now-1]

        l=tuple(l[l[i]-1]for i in range(n))

        k//=2

    print(now)

if __name__ == "__main__":

    f()
def f():

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

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

    now=1

    for d in range(k.bit_length()):

        if k%2:now=l[now-1]

        l=tuple(l[i-1]for i in l)

        k//=2

    print(now)

if __name__ == "__main__":

    f()

def f():
    n, k = list(map(int, input().split()))
    l = list(map(int, input().split()))
    now = 1
    for i in range(k.bit_length()):
        if k % 2:
            now = l[now - 1]
        l = tuple(l[l[i] - 1] for i in range(n))
        k //= 2
    print(now)


if __name__ == "__main__":
    f()

def f():
    n, k = list(map(int, input().split()))
    l = list(map(int, input().split()))
    now = 1
    for d in range(k.bit_length()):
        if k % 2:
            now = l[now - 1]
        l = tuple(l[i - 1] for i in l)
        k //= 2
    print(now)


if __name__ == "__main__":
    f()

-    for i in range(k.bit_length()): +    for d in range(k.bit_length()): -        l = tuple(l[l[i] - 1] for i in range(n)) +        l = tuple(l[i - 1] for i in l)