#P10693. Tree Kingdom Celebration Seating

    ID: 12723 Type: Default 1000ms 256MiB

Tree Kingdom Celebration Seating

Tree Kingdom Celebration Seating

In the Tree Kingdom, a grand celebration is in preparation!

Shirost, the celebration designer, plans to invite (n) guests and has (2n) seats available. Each seat accommodates at most one person and every guest sits exactly in one seat. The initial plan is to assign guest (i) to seat (i). However, the president surveyed the guests: the (i)th guest prefers to sit in seat (a_i). A guest is only willing to change from the original seat if they get their favourite seat. The president now demands that Shirost modify the seating plan so that as many guests as possible get their favourite seats.

Formally, you need to choose an array (b) of length (n) (with (1 \le i \le n) and (1 \le b_i \le 2n)) that satisfies:
(\forall i \neq j,\ b_i \neq b_j) and for every (i,) (b_i = i) or (b_i = a_i).

You are asked to maximize the number of indices (i) such that (b_i = a_i) and output this maximum count.

inputFormat

The first line contains an integer (n) (number of guests).

The second line contains (n) integers (a_1, a_2, \dots, a_n), where (a_i) is the favourite seat of the (i)th guest. Note that (1 \le a_i \le 2n).

outputFormat

Output a single integer: the maximum number of guests who can be assigned their favourite seat while satisfying the seating restrictions.

sample

2
2 2
1