program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,k,i,f,l,next,ans,ii
    integer(int64), allocatable:: a(:),ind(:),lp(:)
    logical,allocatable:: went(:)


    read*, n,k
    allocate(a(n),ind(n))
    allocate(went(n))
    read*, a(:)
    went(:) = .false.
    i=0
    f=0
    l=0

    if (n >= k) then
        ans = 1
        do i=1,k
            ans = a(ans)
        end do
        print'(i0)', ans
        stop
    end if


    next = 1
    i=1
    ind(:) = 0
    do
        if (went(next)) exit
        went(next) = .true.
        ind(next) = i
        next = a(next)
        i=i+1
    end do
    f = ind(next)
    l = i
    allocate(lp(0:l-f-1))
    do ii=0,l-f-1
        lp(ii) = next
        next = a(next)
    end do
    print'(i0)', lp(mod(k-f+1,l-f))
end program main