program dm
    implicit none
    integer::N
    integer(16)::K
    integer,allocatable,dimension(:)::A
    integer,allocatable,dimension(:)::num,town
    integer::now
    integer::loop
    integer::S
    integer::ans
    read*,N,K
    allocate(A(N))
    read*,A
    allocate(num(N),town(N))
    num=-1
    num(1)=1
    now=1
    town(1)=1
    do
        if(num(A(now))<0)then
            num(A(now))=num(now)+1
            town(num(now)+1)=A(now)
            now=A(now)
        else
            exit
        endif
    end do
    loop=num(now)-num(A(now))+1
    S=num(A(now))-1
    if(K>S)then
        K=K-S
        K=mod(K,loop)
        ans=town(1+S+K)
    else
        ans=town(K+1)
    endif
    print"(i0)",ans
contains
end program dm