LCA#3298

LCA

2 segundos
128 megabytes
Media (≈1350)

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 .

Entrada

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 .

Salida

Print one number — the number of pairs.

Ejemplos

Ejemplo 1

Loading
Loading

Ejemplo 2

Loading
Loading