A network has n devices labeled 1 through n. Initially every device is isolated. You then apply m merge operations one at a time; each operation names two devices and places them (and everything already grouped with either of them) into the same group. A device may be merged with itself, and the same pair may be merged more than once — such operations simply have no effect. After all merges, report how many distinct groups (connected components) remain.
Input format
- Line 1: two integers
nandm— the number of devices and the number of merge operations. - The next
mlines: each contains two integersuandv(1-indexed) — merge the groups containinguandv.
Output format
A single integer: the number of connected components after all merges.
Constraints
- 1 ≤ n ≤ 200000
- 0 ≤ m ≤ 200000
- 1 ≤ u, v ≤ n