program ABC167D
    implicit none
    integer(16)::N,K,i
    integer(16),allocatable,dimension(:)::A,B
    read*,N,K
    allocate(A(N))
    allocate(B(N))
    read*,A
    B(1)=1
    i=2
    do
        if(A(B(i-1))==1)exit
        B(i)=A(B(i-1))
        i=i+1
    end do
    i=i-1
    print'(i0)',B(mod(K,i)+1)
    
end program ABC167D