program main
    implicit none
    integer(8) n, k 
    integer(8), allocatable, dimension(:) :: a,b
    integer(8) i,temp, rest, d
    read(*,*) n,k
    allocate(a(n))
    allocate(b(n))
    read(*,*) a

    do i = 1,n
        b(i) = 0
    end do

    temp = 1
    b(1) = 0
    rest = 0
    do i = 1, k
        temp = a(temp)
        if(b(temp) /= 0) then
            d = i - b(temp)
            rest = mod((k-i),d)
            exit
        else if (temp == 1) then
            d = i
            rest = mod((k-i),d)
            exit
        else
            b(temp) = i
        end if
    end do


    if (rest /= 0) then
        do i = 1, rest
            temp = a(temp)
        end do
    end if

    write(*,*) temp

end program