#ARC111B. [ARC111B] Reversible Cards

[ARC111B] Reversible Cards

Score : 400400 points

Problem Statement

We have NN cards numbered 11 to NN. Each side of each card has a color represented by a positive integer.

One side of Card ii has a color aia_i, and the other side has a color bib_i.

For each card, you can choose which side shows up. Find the maximum possible number of different colors showing up.

Constraints

  • 1N2000001 \leq N \leq 200000
  • 1ai,bi4000001 \leq a_i,b_i \leq 400000
  • All numbers in input are integers.

Input

Input is given from Standard Input in the following format:

NN

a1a_1 b1b_1

a2a_2 b2b_2

::

aNa_N bNb_N

Output

Print the answer.

4
1 2
1 3
4 2
2 3
4

We can choose the sides with 11, 33, 44, 22 to have four colors.

2
111 111
111 111
1

They are painted with just one color.

12
5 2
5 6
1 2
9 7
2 7
5 5
4 2
6 7
2 2
7 8
9 7
1 8
8