시간 제한메모리 제한제출정답맞힌 사람정답 비율
10 초 2048 MB641100.000%

문제

You are given a permutation $a_1, \ldots, a_n$. You need to maintain a sequence $b_1, \ldots, b_n$ initialized by zeroes. Process $m$ operations of the following form:

  • Modification operation: given $\ell$ and $r$, for each pair $(i, j)$ such that $\ell \leq i \leq j \leq r$ and $a_i \leq a_j$, increment $b_j$ by $1$;
  • Query operation: given $x$, return $b_x$.

입력

The first line of input contains two integers $n$ and $m$ ($1 \leq n, m \leq 2 \cdot 10^5$).

The second line contains $n$ integers $a_1, \ldots, a_n$ ($1 \leq a_i \leq n$; all $a_i$ are distinct).

Each of the next $m$ lines consists of integers and has either the form "1 $\ell$ $r$" for a modification operation or the form "2 $x$" for a query operation ($1 \leq \ell \leq r \leq n$; $1 \leq x \leq n$).

You may assume that the input contains at least one query operation.

출력

For each query operation, output one line containing an integer that represents the answer.

예제 입력 1

8 10
5 4 8 7 1 6 3 2
1 2 5
2 8
1 2 8
1 7 8
2 4
2 1
2 6
2 4
1 8 8
2 4

예제 출력 1

0
4
0
3
4
4