LearnPy Hub
← Arena
AdvancedRating 1900

Strongly Connected Groups

In a directed graph, two nodes are in the same group if each can reach the other. Print the number of groups.

Input

n and m; then m lines 'u v' (edge u → v).

Output

One integer.

Sample 1

Input
5 5
1 2
2 3
3 1
3 4
4 5
Output
3

Sample 2

Input
3 0
Output
3
solution.py
Output appears here
Strongly Connected Groups · Python Arena problem · LearnPy Hub