The Bovine Shuffle (Silver)#10514

The Bovine Shuffle (Silver)

1 second
128 megabytes
Medium

Convinced that happy cows produce more milk, Farmer John has installed a giant disco ball in his barn and plans to teach his cows to dance!

After looking up popular cow dances, Farmer John decides to teach his cows the "Bovine Shuffle". The Bovine Shuffle consists of his cows lining up in a row in some order and then performing a sequence of "shuffles", each of which may change the order of the cows. To make it easier for his cows to locate themselves, Farmer John labels the positions in the row with the numbers 1, \ldots, n. Thus, the first cow in the lineup occupies position , the next cow occupies position , and so on, up to position .

A shuffle is described by numbers, a_1, \ldots, a_n, where a cow in position moves to position a_i during the shuffle. Each a_i is in the range 1, \ldots, n. Every cow moves to a new position during the shuffle. Unfortunately, the a_i values are not necessarily distinct, so multiple cows may move to the same position during a shuffle. Once this happens, those cows will move together for all subsequent shuffles.

Farmer John notices that some positions in the lineup contain cows regardless of how many shuffles take place. Please help him count the number of such positions.

Input

The first line contains n~(1 \le n \le 10^5), the number of cows. The next line contains the integers a_1, \ldots, a_n describing the shuffle.

Output

Print the number of positions that will always contain cows, regardless of how many shuffles take place.

Examples

Example 1

Loading
Loading