luogu#P6153. 询问

询问

Background

zbw was invited to a kindergarten to create problems for children.

Problem Description

Now zbw has nn items, numbered from 1n1 \sim n. He will tell you mm conditions. Each condition contains two numbers x,yx, y, meaning that item xx and item yy are the same.

Because zbw is in a big hurry, he guarantees that every condition he gives is useful; that is, each condition cannot be deduced from the previous conditions.

You need to answer how many different kinds of items there are.

Input Format

The first line contains two integers nn and mm.

Then follow mm lines. Each line contains two numbers x,yx, y, meaning that item xx and item yy are the same.

Output Format

Output one integer: the number of different items.

11 8 
1 2
4 3
5 4
1 3
5 6
7 10
5 10
8 9
3

Hint

For 20%20\% of the testdata, n,m10n, m \le 10.

For 40%40\% of the testdata, n,m103n, m \le 10^3.

For 60%60\% of the testdata, n,m105n, m \le 10^5.

For 80%80\% of the testdata, m106m \le 10^6.

For 100%100\% of the testdata, 1n10181 \le n \le 10^{18}, 1m1071 \le m \le 10^7.

Translated by ChatGPT 5