The directed graph is given. How many pairs of vertices (i,j) have the common ancestor? The common ancestor of vertices i and j is a vertex k for which i and j are reachable from k.
The first line contains the number of vertices n (1≤n≤104) and number of edges m (0≤m≤104) in a graph. Each of the next m lines contains two numbers from 1 to n. The pair (a,b) means that an edge goes from a to b.
Print the number of pairs.