P26319 [AtCoder] Number of Types β
NOI
题目描述

Problem Description

There are $ N $ pairs of integers. The $ i $ -th pair of integers is $ (A_i, B_i) $.

Snuke is trying to choose exactly one integer from each pair. What is the maximum number of different integers that can be chosen from these $ N $ pairs?

Input Format

The input is given from the standard input in the following format:

$ N $ $ A_1 $ $ B_1 $ $ A_2 $ $ B_2 $ $ : $ $ A_N $ $ B_N $

Output Format

Output the maximum number of different integers that Snuke can choose from these $ N $ pairs.

Sample Input and Output

Sample Input #1

5
58 48
58 58
20 19
58 425
48 425

Sample Output #1

4

Sample Input #2

3
1000000000 1000000000
1000000000 1000000000
1000000000 1000000000

Sample Output #2

1

Notes/Hints

Constraints

The input satisfies the following conditions:

  • $1 \leq N \leq 2 \times 10^5$
  • $1 \leq A_i, B_i \leq 10^9$
  • All input values are integers.

Sample Explanation 1

Choosing $ 58, 58, 20, 425, 48 $ from each pair respectively allows you to choose 4 different integers. It is not possible to choose 5 or more different integers.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 58 48 58 58 20 19 58 425 48 425
样例输出
4