#include <bits/stdc++.h>using namespace std;
queue <int> X,Y;
bool Marked[8][8];
void StartProcess()
{
for (int i=0; i<8; i++)
for (int j=0; j<8; j++) Marked[i][j]=false;
int n;
cin >> n;
for (int i=0; i<n; i++)
{
int x,y;
cin >> x >> y;
Marked[x-1][y-1]=true;
}
}
bool Found(int &x, int &y)
{
for (int i=0; i<8; i++)
for (int j=0; j<8; j++)
if (not Marked[i][j])
{ x=i; y=j; return true;};
return false;
}
void PutAll(int x, int y)
{
int steps[4][2] = {{0,-1},{0,1},{-1,0},{1,0}};
for (int i=0; i<4; i++)
{
int Cx=x+steps[i][0];
int Cy=y+steps[i][1];
if ((Cx>=0) && (Cx<8) &&
(Cy>=0) && (Cy<8) &&
(not Marked[Cx][Cy]))
{X.push(Cx); Y.push(Cy); Marked[Cx][Cy]=true;};
}
}
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
StartProcess();
int PieceNumber=0,x,y;
while (Found(x,y))
{
PieceNumber++;
X.push(x); Y.push(y); Marked[x][y]=true;
while (not X.empty())
{
x=X.front(); X.pop();
y=Y.front(); Y.pop();
PutAll(x,y);
}
}
cout << PieceNumber; }