Count Connected Components

VERY EASY · C · 2000ms

Network admin Rakib is mapping the university's internal server network. First task: count how many separate isolated clusters of machines exist. Given an undirected graph with N nodes and M edges, print the number of connected components.

Input

Line1: N M. Next M lines: u v (an edge).

Output

Number of connected components.

Constraints

1 ≤ N ≤ 10^5, 0 ≤ M ≤ 2×10^5

Sample Input

5 2
1 2
2 3

Sample Output

3
main.c
Loading editor…

Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.

Count Connected Components · DIU ContestHub