      program teleporter
      implicit none
      integer(16) :: n,k
      integer(16),allocatable :: a(:),visitNum(:)
      logical,allocatable :: isVisited(:)
      integer(16) :: numTele,now,loopSize,loopPoint
      
      read*,n,k
      allocate( a(n) )
      read*,a(1:n)
      
      allocate( isVisited(n),source=.false. )
      allocate( visitNum(n) )
      
      numTele = 0
      now = 1
      visitNum(now) = numTele
      isVisited(now) = .true.
      do while(.true.)
        numTele = numTele + 1
        now = a(now)
        if( isVisited(now) )then
          loopSize = numTele - visitNum(now)
          loopPoint = now
          exit
        else
          isVisited(now) = .true.
          visitNum(now) = numTele
        end if
      end do
      
      
      now = 1
      if( loopPoint==now )then
        k = k - k/loopsize*loopsize
        if( k==0 )then
          print*,'1';stop
        end if
      end if
      do while( .true. )
        k = k - 1
        now = a(now)
        if( loopPoint==now )then
          k = k - k/loopsize*loopsize
        end if
        
        if( k==0 )then
          print*,now;stop
        end if
      end do
      
      
      
      
      
      
      !debugg
      print*,n,k
      print*,a(1:n)
      print*,visitNum
      print*,isVisited
      print*,'loopsize: ',loopSize
      print*,'loopPoint: ',loopPoint
      
      end program