Kosaraju Algorithm
easy
You are given a graph with N nodes and M directed edges. Find the number of Strongly connected components in the graph.
Constraints
1<= N <= 10000 1<= M <= (N*(N-1))/2 1<= ai, bi <= N
Format
Input
First line contains two space separated integers,N and M. Then M lines follow, each line has 2 space separated integers ai and bi.
Output
Print in one line the number of strongly connected components in the graph.
Example
Sample Input
5 6
1 4
1 3
2 4
3 4
4 5
5 1
Sample Output
2