Problem F: Connect all cities

Problem F: Connect all cities

Time Limit: 1 Sec  Memory Limit: 1024 MB
Submit: 909  Solved: 198
[Submit][Status][Web Board]


There are n cities and m roads, each road is unidirectional. Sinzo wants to build some roads, to make each city can reach other cities. Please tell how many roads should Sinzo construct at least?


The first line contains two integers, n, m \((1\leq n, m\leq 10^5)\), indicating the number of cities and the number of roads. 

The next m lines, each line contains two integers u, v, indicating there is a unidirectional road from u to v.


Please output the number of roads to construct in one line.

Sample Input

4 4
1 2
2 3
3 1
3 4

Sample Output