LCA#3298

LCA

2 secondi
128 megabyte
Media

The directed graph is given. How many pairs of vertices have a common ancestor? The common ancestor of vertices and is a vertex for which and are reachable from .

Input

The first line contains integers and m~(1 \le n \le 10^4, 0 \le m \le 10^4) — the number of vertices and edges in the graph. Each of the next lines contains two numbers from to . The pair means that an edge goes from to .

Output

Print one number — the number of pairs.

Esempi

Esempio 1

Loading
Loading

Esempio 2

Loading
Loading