LearnPy Hub
← Arena
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
solution.py
Output appears here
Islands of Friends · Python Arena problem · LearnPy Hub