You are given a regular polygon with n vertices, and m of its diagonals have been selected. Count how many pairs of the selected diagonals cross each other. Two diagonals cross when they intersect strictly inside the polygon; two diagonals that share only a common vertex (endpoint) are not counted as crossing.
Write a program that:
The first line contains two integers n and m, separated by a single space, where n is the number of vertices of the polygon and m is the number of selected diagonals (4≤n≤1000000, 2≤m≤10000000).
Each of the next m lines describes one diagonal. The i-th of these lines contains two integers ai and bi (1≤ai,bi≤n), separated by a single space, denoting the diagonal that joins vertex ai with vertex bi. The vertices of the polygon are numbered from 1 to n in counter-clockwise order.
You may assume that every pair of numbers describes a valid diagonal (never a single vertex, and never an edge of the polygon), and that all diagonals in the input are distinct.
Print a single integer: the number of pairs of selected diagonals that cross. If no pair of diagonals crosses, print 0.

In the picture above, the solid lines and the dashed lines show two different sets of selected diagonals on the same polygon.