D. Darkness II
time limit per test
6 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

Princess Celestia and Princess Luna argued, and the spreading darkness could be transformed into the following model:

In an infinitely large white 2D grid, there are initially $$$n$$$ black grid points.

Every second, all white points that are 4-neighbors of at least two black points will turn black.

What is the total number of black points in the end?

Time to put our differences behind us. We were meant to rule together, little sister. Will you accept my friendship?
— Celestia offering Luna redemption
Input

The first line contains an integer $$$n$$$ $$$(1\le n\le 10^5)$$$, representing the total number of grid points.

The next $$$n$$$ lines each contain two integers $$$a$$$ and $$$b$$$ $$$(-10^{9}\le a,b\le 10^9)$$$, representing the positions of black grid points. The black points are guaranteed to be distinct from each other.

Output

Output a single integer representing the total number of black points in the end.

Example
Input
7
1 1
1 4
2 2
3 4
5 5
6 7
7 6
Output
21
Note

The change of the grid over time is shown below. After Time $$$6$$$ no more grid will turn black, so the answer is $$$21$$$.