You are playing hopscotch on a one-indexed array of integers. You can choose to start at some index (which is undecided). Your goal is to reach index . This game of hopscotch is strange. At index , it is already defined where you must hop to. At index , you must hop to index .
You want to find out, for how many starting indices will you be able to reach index ?
Input Specification
The first line will contain the integer , the number of elements.
The second line will contain integers, .
Output Specification
Output the number of starting indices where you will be able to reach index .
Subtasks
For 3/15 of the points, .
For an additional 4/15 of the points, .
Sample Input
6
5 2 2 2 3 1
Sample Output
4
Explanation For Sample
You will be able to reach index when starting at indices or .
Comments