#include <bits/stdc++.h>

using namespace std;

struct zlatnik{
    int red;
    int kolona;
};

bool provera(zlatnik a[], int n, int x, int y, int indeks){
    if(x < 1 || y < 1 || x > n || y > n)
        return false;
    for(int i = 0;i < n;i++)
        if(i != indeks){
            if(a[i].red == x || a[i].kolona == y)
                return false;
        }
    return true;
}

int brPoteza(zlatnik a[], int n){
    int potezi = 0;
    for(int i = 0;i < n;i++){
        if(provera(a, n, a[i].red - 1, a[i].kolona, i)){
            a[i].red -= 1;
            potezi++;
        }
        else if(provera(a, n, a[i].red, a[i].kolona + 1, i)){
            a[i].kolona += 1;
            potezi++;
        }
        else if(provera(a, n, a[i].red + 1, a[i].kolona, i)){
            a[i].red += 1;
            potezi++;
        }
        else if(provera(a, n, a[i].red, a[i].kolona - 1, i)){
            a[i].kolona -= 1;
            potezi++;
        }
    }
    return potezi;
}

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    zlatnik a[n];
    for(int i = 0;i < n;i++) cin >> a[i]. red >> a[i].kolona;
    cout << brPoteza(a, n);
    return 0;
}