#include <iostream>
using namespace std;
int main() {
int mesh[40][50];
int tempx, tempy;
int row = 0;
int point = 0;
int pointTemp[4];//h,s,p,n
int time=0;
memset(mesh, 0, sizeof(mesh));
memset(pointTemp, 0, sizeof(pointTemp));
cin >> row;
for (int i = 0; i < row; i++) {
cin >> tempx;
cin >> tempy;
mesh[tempx][tempy] = 1;
point++;
}
int cutDir = 0;
for (int x = 0; x < 40; x++) {
for (int y = 0; y < 50; y++) {//find num
if (mesh[x][y] == 1) {//找到就切
time++;
mesh[x][y] = 0;
point--;
for (int h = 0; h < 50; h++) {//横
if (mesh[x][h] == 1) {
pointTemp[0]++;
}
}
for (int s = 0; s < 40; s++) {//竖
if (mesh[s][y] == 1) {
pointTemp[1]++;
}
}
for (int s = 0; s < 40; s++) {
for (int h = 0; h < 50; h++) {
if ((s + h) == (x + y) && mesh[s][h] == 1) {//撇
pointTemp[2]++;
}
}
}
for (int s = 0; s < 40; s++) {
for (int h = 0; h < 50; h++) {
if ((40 + 50 - s + h) == (40 + 50 - x + y) && mesh[s][h] == 1) {//n捺
pointTemp[3]++;
}
}
}
int bigTemp = pointTemp[0];
cutDir = 0;
for (int big = 1; big < 4; big++) {
if (pointTemp[big] > bigTemp) {
bigTemp = pointTemp[big];
cutDir = big;
}
}
switch (cutDir) {
case 0:
for (int h = 0; h < 50; h++) {//横
if (mesh[x][h] == 1) {
mesh[x][h] = 0;
}
}break;
case 1:
for (int s = 0; s < 40; s++) {
if (mesh[s][y] == 1) {
mesh[s][y] = 0;
}
}break;
case 2:
for (int s = 0; s < 40; s++) {
for (int h = 0; h < 50; h++) {
if ((s + h) == (x + y) && mesh[s][h] == 1) {
mesh[s][h] = 0;
}
}
}break;
case 3:
for (int s = 0; s < 40; s++) {
for (int h = 0; h < 50; h++) {
if ((40 + 50 - s + h) == (40 + 50 - x + y) && mesh[s][h] == 1) {
mesh[s][h] = 0;
}
}
}break;
default:break;
}
}
}
}
cout << time <<endl;
return 0;
}