{"raw_statement":[{"iden":"problem statement","content":"You are given a sequence of $N$ numbers: $A=(A_1,A_2,\\ldots,A_N)$. Here, each $A_i$ $(1\\leq i\\leq N)$ satisfies $1\\leq A_i \\leq N$.\nTakahashi and Aoki will play $N$ rounds of a game. For each $i=1,2,\\ldots,N$, the $i$\\-th game will be played as follows.\n\n1.  Aoki specifies a positive integer $K_i$.\n2.  After knowing $K_i$ Aoki has specified, Takahashi chooses an integer $S_i$ between $1$ and $N$, inclusive, and writes it on a blackboard.\n3.  Repeat the following $K_i$ times.\n    *   Replace the integer $x$ written on the blackboard with $A_x$.\n\nIf $i$ is written on the blackboard after the $K_i$ iterations, Takahashi wins the $i$\\-th round; otherwise, Aoki wins.  \nHere, $K_i$ and $S_i$ can be chosen independently for each $i=1,2,\\ldots,N$.\nFind the number of rounds Takahashi wins if both players play optimally to win."},{"iden":"constraints","content":"*   $1\\leq N\\leq 2\\times 10^5$\n*   $1\\leq A_i\\leq N$\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":"3\n2 2 3"},{"iden":"sample output 1","content":"2\n\nIn the first round, if Aoki specifies $K_1=2$, Takahashi cannot win whichever option he chooses for $S_1$: $1$, $2$, or $3$.\nFor example, if Takahashi writes $S_1=1$ on the initial blackboard, the two operations will change this number as follows: $1\\to 2(=A_1)$, $2\\to 2(=A_2)$. The final number on the blackboard will be $2(\\neq 1)$, so Aoki wins.\nOn the other hand, in the second and third rounds, Takahashi can win by writing $2$ and $3$, respectively, on the initial blackboard, whatever value Aoki specifies as $K_i$.\nTherefore, if both players play optimally to win, Takashi wins two rounds: the second and the third. Thus, you should print $2$."},{"iden":"sample input 2","content":"2\n2 1"},{"iden":"sample output 2","content":"2\n\nIn the first round, Takahashi can win by writing $2$ on the initial blackboard if $K_1$ specified by Aoki is odd, and $1$ if it is even.\nSimilarly, there is a way for Takahashi to win the second round. Thus, Takahashi can win both rounds: the answer is $2$."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}