#agc051c. [agc051_c]Flipper

[agc051_c]Flipper

Problem Statement

There is a square grid of dimensions 109times10910^9 \\times 10^9. The cells are numbered (1,1)(1, 1) through (109,109)(10^9, 10^9). Cell (i,j)(i, j) is in the ii-th row from the top, and the jj-th column from the left. Initially, NN cells (x1,y1),ldots,(xN,yN)(x_1, y_1), \\ldots, (x_N, y_N) are black, and all other cells are white.

Snuke can perform the following operation an arbitrary number of times:

  • Choose an integer x(1leqxleq1091)x (1 \\leq x \\leq 10^9 - 1) and an integer y(1leqyleq1092)y (1 \\leq y \\leq 10^9 - 2), and flip (black to white, white to black) the colors of the following six cells: $(x, y), (x, y+1), (x, y+2), (x+1, y), (x+1, y+1), (x+1, y+2)$

Compute the minimum possible number of black cells after the operations.

Constraints

  • 1leqNleq1051 \\leq N \\leq 10^5
  • 1leqxi,yileq1091 \\leq x_i, y_i \\leq 10^9
  • (xi,yi)(x_i, y_i) are pairwise distinct.
  • All values in the input are integers.

Input

Input is given from Standard Input in the following format:

NN x1y1x_1 \\ y_1 :: xNyNx_N \\ y_N

Output

Print the answer.


Sample Input 1

9
1 2
1 3
2 1
2 3
2 4
3 2
3 3
3 4
4 2

Sample Output 1

3

In the diagram below, the jj-th letter of the ii-th string from the top represents the cell (i,j)(i, j). # is black, . is white.

.##.
#.##
.###
.#..

->

#...
.#.#
.###
.#..

->

#...
..#.
....
.#..