CF505D Mr. Kitayuta's Technology
Description
Shuseki Kingdom is the world's leading nation for innovation and technology. There are $ n $ cities in the kingdom, numbered from $ 1 $ to $ n $ .
Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, that is, a teleportation pipe from city $ x $ to city $ y $ cannot be used to travel from city $ y $ to city $ x $ . The transportation within each city is extremely developed, therefore if a pipe from city $ x $ to city $ y $ and a pipe from city $ y $ to city $ z $ are both constructed, people will be able to travel from city $ x $ to city $ z $ instantly.
Mr. Kitayuta is also involved in national politics. He considers that the transportation between the $ m $ pairs of city $ (a_{i},b_{i}) $ ( $ 1
Input Format
The first line contains two space-separated integers $ n $ and $ m $ ( $ 2
Output Format
Print the minimum required number of teleportation pipes to fulfill Mr. Kitayuta's purpose.
Explanation/Hint
For the first sample, one of the optimal ways to construct pipes is shown in the image below:
For the second sample, one of the optimal ways is shown below:
