Arranging Blocks

Time limit1sMemory limit128 MB

Problem

There is a square board with side length N. The board is divided into N * N unit square cells. There are also M unit cube blocks placed on the board. Multiple blocks may be stacked on the same cell.

After cleanup, the blocks must form one rectangle. Every cell inside that rectangle must contain exactly one block, and no block may have another block on top of it.

In one move, you may take the top block from one cell and place it on top of another cell. Given the current positions of all blocks, compute the minimum number of moves needed so that the blocks form one rectangle.

Input

The first line contains the side length of the board N and the number of blocks M. (1 <= N <= 100, 1 <= M <= N^2)

Each of the next M lines contains the coordinates R, C of a cell containing one block. (1 <= R, C <= N)

Output

Print the minimum number of blocks that must be moved to form a rectangle. The input is guaranteed to be a case where some rectangle can be formed.