Problems
Bishops
Bishops
The bishop in chess is a piece that attacks all squares on the same diagonal (on both diagonals).
Shakhriyar placed m bishops on a chessboard of size n * n. Now he wants to count the number of squares that are not attacked by bishops. Help Shahriyar in this matter.
Input
First line contains two integers: the size n (1 ≤ n ≤ 106
) of a chessboard and the number of bishops m (1 ≤ m ≤ 105
). Each of the next m lines contains pair of integers: ri
и ci
(1 ≤ ri
, ci
≤ n) - the numbers of row and column where the bishop number i is located. The bishops are numbered from 1 to m. All bishops are located on different squares.
Output
Print the number of squares not attacked by the bishops.
Input example #1
10 6 4 7 8 5 8 7 6 2 9 7 8 4
Output example #1
33
Input example #2
6 1 5 4
Output example #2
28
Input example #3
8 2 4 3 5 6
Output example #3
42