378. Where Can You Start
The edges here are DIRECTED. An edge u v means you may go from u to v
and not the other way.
The in-degree of a vertex is how many edges point INTO it. A vertex with in-degree 0 is a source: nothing leads to it, so it is somewhere a walk through the graph could begin. Print how many sources the graph has.
Everything before this problem in the topic treated edges as two-way and pushed
each one into both adjacency lists. That is exactly what must not happen now.
Reading u v increases the in-degree of v only.
Two answers are worth understanding rather than just producing. A graph with no edges is all sources, and a graph that is one big directed cycle has none, because every vertex has something pointing at it.
Constraints - `1 ≤ n ≤ 100000` - `0 ≤ m ≤ 200000` - There are no self-loops and no repeated edges.
Input
The first line contains two integers n and m, the number of vertices and
directed edges. Each of the next m lines contains two integers u and v,
a directed edge from u to v. Vertices are numbered 1 to n.
Output
Print one integer, the number of vertices with in-degree 0.