IntermediateRating 1300
Islands of Friends
Count the connected groups in an undirected graph.
Input
n m, then m lines 'u v'.
Output
A count.
Sample 1
Input
5 3 1 2 2 3 4 5
Output
2
Sample 2
Input
3 0
Output
3
Output appears heren m, then m lines 'u v'.
A count.
5 3 1 2 2 3 4 5
2
3 0
3
Output appears here