output_description: If T satisfies the property in Problem Statement, print `Yes`; otherwise,
  print `No`.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
      T
attempt: def parse():
      N, K = map(int, input().split(" "))
      A = []
      for a in input().split(" "):
          A.append(int(a) - 1)
      return N, K, A
  
  
  def fast_pow(x, n):
      """
      O(log n)
      """
      if n == 0:
          return 1
  
      K = 1
      while n > 1:
          if n % 2 != 0:
              K *= x
          x *= x
          n //= 2
  
      return K * x
  
  
  def fast_mod(x, N):
      if N % 2 == 0:
          return x & (fast_pow(2, N) - 1)
      else:
          return x % N
  
  
  def main():
      N, K, A = parse()
      # print(N, K, A)
  
      # 経路の計算
      route = []
      next_town = A[0]
      town = 0
      while not (next_town in route):  # 既出の町に行く場合
          route.append(town)
          next_town = A[town]
          town = next_town
      once_route = route[: route.index(next_town)]
      loop_route = route[route.index(next_town) :]
      # print("once_route:", once_route)
      # print("loop_route:", loop_route)
  
      # print([town + 1 for town in route])
      # print("K %% len(loop_route):", K % len(loop_route))
      # print(route[K % len(loop_route) + len(once_route)] + 1)
      if K > len(route) and len(once_route) > 0:
          # print("loop")
          loop_K = K - len(route)
          print(loop_route[fast_mod(loop_K, len(loop_route))] + 1)
          # print(loop_route[loop_K % len(loop_route)] + 1)
      else:
          # print("normal")
          # print(route[fast_mod(K, len(loop_route))] + 1)
          # print("K:", K)
          # print("K %% len(route):", K % len(route))
          print(route[fast_mod(K, len(route))] + 1)
          # print(route[K % len(route)] + 1)
  
  
  if __name__ == "__main__":
      main()
  
problem_description: Statement
  
  Takahashi wants to be a member of some web service.
  
  He tried to register himself with the ID S, which turned out to be already
  used by another user.
  
  Thus, he decides to register using a string obtained by appending one
  character at the end of S as his ID.
  
  He is now trying to register with the ID T. Determine whether this string
  satisfies the property above.
samples: [{"input": "chokudai\n    chokudaiz", "output": "Yes\n    \n\n`chokudaiz` can be obtained by appending `z` at the end of `chokudai`.\n\n* * *"}, {"input": "snuke\n    snekee", "output": "No\n    \n\n`snekee` cannot be obtained by appending one character at the end of `snuke`.\n\n* * *"}, {"input": "a\n    aa", "output": "Yes"}]