import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val K = in.next().toLong
  val A = new Array[Int](N+1)
  for (i <- 1 to N)
    A(i) = in.next().toInt

  //
  val dp = Array.fill[Int](N+1)(-1)
  var now = A(1)
  var cnt = 0
  var vol = -1
  breakable {
    while (true) {
      if (dp(now) == -1) {
        cnt += 1
        dp(now) = cnt
        now = A(now)
      }
      else {
        vol = dp(now) - 1
        break
      }
    }
  }


  if (K < cnt) {
    val k = K
    for (i <- 1 to N) {
      if (dp(i) == k)
        println(i)
    }
  }
  else {
    val m = (cnt-vol)
    var k = (K-cnt) % m
    if (k == 0) k = m
    for (i <- 1 to N) {
      if (dp(i) - vol == k)
        println(i)
    }
  }

}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
