Reachability - MarisaOJ: Marisa Online Judge

Reachability

Time limit: 1000 ms
Memory limit: 256 MB
Given a directed graph with n vertices and m edges, find the number of vertices that can be reached from every other vertex in the graph. ### Input - The first line contains 2 integers n,m. - The next m lines, each line contains two integers u,v, there is an edge between u and v. ### Output - Print the number of satisfied vertices. ### Constraints - 1≤n,m≤5×105. - 1≤m≤106. - 1≤u,v≤n. ### Example Input: 651323344546 Output: 0