408312: GYM103091 L Ambiguous
Description
Stan Ford is a city planner who has been hired by MTL, Stanford's president, to solve a very important problem. Stan has been tasked with finding a new location for Stanford's campus. As lovely as Palo Alto is, Stanford has grown tired of being so close to Berkeley and wants to move to the great state of Kansas.
Within Kansas, there are $$$N$$$ cities, and $$$M$$$ one directional roads that connect cities. In Kansas, it is guaranteed that if you leave from a city, it is impossible to return to that city by traveling along the roads.
Stan Ford needs to find a city that is ambiguous to report back to MTL. A city, $$$u$$$, is ambiguous if for every other city $$$v$$$, Stan can either walk from $$$u$$$ to $$$v$$$, or from $$$v$$$ to $$$u$$$. During these walks, he can of course pass through other cities that aren't $$$u$$$ or $$$v$$$.
However, MTL is quite meticulous, and wants to make sure that he is able to consider all possible home cities for Stanford. Thus, he wants to know from Stan Ford, the number of ambiguous cities that exist in Kansas. Poor Stan is tired of walking, and asks for your help in counting the number of ambiguous cities!
InputThe first line will contain two space separated integers $$$N$$$ and $$$M$$$ ($$$ 2 \leq N \leq 200,000$$$, $$$1 \leq M \leq 200,000$$$) which represents the number of cities and roads respectively. The next $$$M$$$ lines will contain two space separated integers $$$u$$$ and $$$v$$$ ($$$ 1 \leq u, v \leq N$$$) which means there is a road from city $$$u$$$ to city $$$v$$$.
OutputOutput a single integer, the number of ambiguous cities in the graph.
ExampleInput4 4 1 2 1 3 2 4 3 4Output
2