{"raw_statement":[{"iden":"problem statement","content":"Given is a sequence $p$ of length $N+M$, which is a permutation of $(1,2 \\ldots, N+M)$. The $i$\\-th term of $p$ is $p_i$.\nYou can do the following **Operation** any number of times.\nOperation: Choose an integer $n$ between $1$ and $N$ (inclusive), and an integer $m$ between $1$ and $M$ (inclusive). Then, swap $p_{n}$ and $p_{N+m}$.\nFind the minimum number of Operations needed to sort $p$ in ascending order. We can prove that it is possible to sort $p$ in ascending order under the Constraints of this problem."},{"iden":"constraints","content":"*   All values in input are integers.\n*   $1 \\leq N,M \\leq 10^5$\n*   $1 \\leq p_i \\leq N+M$\n*   $p$ is a permutation of $(1,2 \\ldots, N+M)$."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $M$\n$p_{1}$ $\\cdots$ $p_{N+M}$"},{"iden":"sample input 1","content":"2 3\n1 4 2 5 3"},{"iden":"sample output 1","content":"3"},{"iden":"sample input 2","content":"5 7\n9 7 12 6 1 11 2 10 3 8 4 5"},{"iden":"sample output 2","content":"10"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}