nebuni

Time limit: 0.1s Memory limit: 64MB Input: nebuni.in Output: nebuni.out

There are MM bishops placed on a chessboard with NN lines and NN columns. As we know from the game of chess, the bishops attack only on the diagonals.

A position from the chessboard is considered safe if it's not attacked by any of the bishops on the board.

Task

Write a program which finds the number of safe positions on the chessboard.

Input data

The input file nebuni.in contains on the first line the integers NN and MM, separated by a space, which represent the dimensions of the chessboard, as well as the number of bishops on the chessboard. On the next MM lines we have the positions (line and column, separated by a space) of the MM bishops, each bishop's place is on a different line of the file.

Output data

The output file nebuni.out will contain a single line where a single integer will be written, representing the number of safe positions on the given chessboard.

Constraints and clarifications

  • 1N1061 \leq N \leq 10^6
  • 1M<16 5001 \leq M < 16 \ 500
  • The lines and columns are numbered from 11 to NN.
  • For 50%50\% of the test cases, N300N \leq 300.
  • For 60%60\% of the test cases, M1 000M \leq 1 \ 000.

Example

nebuni.in

5 4
2 1
1 3
4 2
5 2

nebuni.out

6

Explanation

There are 44 bishops on the 5×55 \times 5 chessboard.

The positions attacked by the 44 bishops are colored in gray.

Log in or sign up to be able to send submissions!