#abc277a. A - ^{-1}

A - ^{-1}

Score : 100100 points

问题描述

给定一个序列 PP,它是 (1,2,,N)(1,2,\dots,N) 的一个排列,并给定一个整数 XX。序列 PP 的第 ii 项的值为 PiP_i。请输出满足 Pk=XP_k = Xkk 值。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given a sequence PP that is a permutation of (1,2,,N)(1,2,…,N), and an integer XX. The ii-th term of PP has a value of PiP_i. Print kk such that Pk=XP_k = X.

Constraints

  • 1N1001 \leq N \leq 100
  • 1XN1 \leq X \leq N
  • PP is a permutation of (1,2,,N)(1,2,…,N).
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN XX

P1P_1 P2P_2 \ldots PNP_N

Output

Print the answer.

Sample Input 1

4 3
2 3 1 4

Sample Output 1

2

We have P=(2,3,1,4)P = (2,3,1,4), so P2=3P_2 = 3. Thus, you should print 22.

Sample Input 2

5 2
3 5 1 4 2

Sample Output 2

5

Sample Input 3

6 6
1 2 3 4 5 6

Sample Output 3

6

update @ 2024/3/10 11:38:53