{"raw_statement":[{"iden":"problem statement","content":"You are given a sequence $A=(A_1,A_2,\\ldots,A_N)$ of length $N$, consisting of integers between $1$ and $4$.\nTakahashi may perform the following operation any number of times (possibly zero):\n\n*   choose a pair of integer $(i,j)$ such that $1\\leq i<j\\leq N$, and swap $A_i$ and $A_j$.\n\nFind the minimum number of operations required to make $A$ non-decreasing.  \nA sequence is said to be non-decreasing if and only if $A_i\\leq A_{i+1}$ for all $1\\leq i\\leq N-1$."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 2\\times 10^5$\n*   $1\\leq A_i \\leq 4$\n*   All values in the input are integers."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\ldots$ $A_N$"},{"iden":"sample input 1","content":"6\n3 4 1 1 2 4"},{"iden":"sample output 1","content":"3\n\nOne can make $A$ non-decreasing with the following three operations:\n\n*   Choose $(i,j)=(2,3)$ to swap $A_2$ and $A_3$, making $A=(3,1,4,1,2,4)$.\n*   Choose $(i,j)=(1,4)$ to swap $A_1$ and $A_4$, making $A=(1,1,4,3,2,4)$.\n*   Choose $(i,j)=(3,5)$ to swap $A_3$ and $A_5$, making $A=(1,1,2,3,4,4)$.\n\nThis is the minimum number of operations because it is impossible to make $A$ non-decreasing with two or fewer operations.  \nThus, $3$ should be printed."},{"iden":"sample input 2","content":"4\n2 3 4 1"},{"iden":"sample output 2","content":"3"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}