Bishops
Medium
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
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 ≤ 10^6
) of a chessboard and the number of bishops m (1 ≤ m ≤ 10^5
). Each of the next m lines contains pair of integers: r[i]
и c[i]
(1 ≤ r[i]
, c[i]
≤ 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.
Examples
Input #1
Answer #1
Input #2
Answer #2
Input #3
Answer #3
Submissions 625
Acceptance rate 17%