Given an undirected graph, print the number of connected components.
Input
First line $N$ ($1 \le N \le 1000$) and $M$ ($0 \le M \le 1000$); then $M$ lines each with an edge $u$, $v$ ($u \ne v$). Multiple edges may appear.
Output
Print the number of connected components.
Example 1
Input
6 5 1 2 2 5 5 1 3 4 4 6
Output
2
Example 2
Input
6 2 3 4 4 2
Output
4
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.