102770: [AtCoder]ABC277 A - ^{-1}

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:2 Solved:0

Description

Score : $100$ points

Problem Statement

You are given a sequence $P$ that is a permutation of $(1,2,…,N)$, and an integer $X$. The $i$-th term of $P$ has a value of $P_i$. Print $k$ such that $P_k = X$.

Constraints

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

Input

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

$N$ $X$
$P_1$ $P_2$ $\ldots$ $P_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)$, so $P_2 = 3$. Thus, you should print $2$.


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

Input

题意翻译

【题面翻译】 给定一个长度为 $n$ 的排列 $P$,以及一个数字 $X$($1 \le X \le n$)。求排列中,第几位的元素为 $X$。 translated by [liangbowen](https://www.luogu.com.cn/user/367488).

Output

分数:100分

问题描述

给你一个序列$P$,它是$(1,2,…,N)$的一个排列,以及一个整数$X$。$P$的第$i$项的值为$P_i$。打印出$k$,使得$P_k = X$。

限制条件

  • $1 \leq N \leq 100$
  • $1 \leq X \leq N$
  • $P$是$(1,2,…,N)$的一个排列。
  • 输入中的所有值都是整数。

输入

输入从标准输入以以下格式给出:

$N$ $X$
$P_1$ $P_2$ $\ldots$ $P_N$

输出

打印答案。


样例输入1

4 3
2 3 1 4

样例输出1

2

我们有$P = (2,3,1,4)$,所以$P_2 = 3$。因此,你应该打印出$2$。


样例输入2

5 2
3 5 1 4 2

样例输出2

5

样例输入3

6 6
1 2 3 4 5 6

样例输出3

6

加入题单

算法标签: