#include <bits/stdc++.h>
using namespace std;
#define pii array<int,2>
pii operator+(const pii &x, const pii &y) {
return {x[0]+y[0], x[1]+y[1]};
}
const int GRID = 1000;
// counts the number of times a square is visited
int cnt[GRID][GRID];
bool inside[GRID][GRID];
vector<vector<int>> dist(GRID, vector<int>(GRID, 1e9));
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n;
pii p;
for (int i=0;i<n;i++) {
int x,y;cin>>x>>y;
inside[x][y] = true;
p = {x, y};
}
priority_queue<pair<int, pii>> pq;
pq.push(make_pair(0, p));
dist[p[0]][p[1]] = 0;
int ans = 0;
auto check=[&](pii x) {
return x[0] >= 0 && x[0] < GRID && x[1] >= 0 && x[1] < GRID;
};
vector<pii> dir = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
vector<vector<int>> cnt(GRID, vector<int>(GRID, 0));
while (!pq.empty()) {
auto [d, e] = pq.top();
int a = e[0];
int b = e[1];
pq.pop();
if (dist[a][b] != -d) continue;
if (inside[a][b]) {
dist[a][b] = 0;
}
cnt[a][b]++;
for (auto &x:dir) {
pii nw = x+e;
if (!check(nw)) continue;
if (dist[nw[0]][nw[1]] > dist[a][b]+1) {
dist[nw[0]][nw[1]] = dist[a][b]+1;
pq.push({-(dist[a][b]+1), nw});
}
}
}
// find the maximum number of visits
int mx = 0;
for (int i=0;i<GRID;i++) {
for (int j=0;j<GRID;j++) {
mx = max(mx, cnt[i][j]);
}
}
cout<<mx<<"\n";
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIHBpaSBhcnJheTxpbnQsMj4KCnBpaSBvcGVyYXRvcisoY29uc3QgcGlpICZ4LCBjb25zdCBwaWkgJnkpIHsKICAgIHJldHVybiB7eFswXSt5WzBdLCB4WzFdK3lbMV19Owp9Cgpjb25zdCBpbnQgR1JJRCA9IDEwMDA7CgovLyBjb3VudHMgdGhlIG51bWJlciBvZiB0aW1lcyBhIH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gIGlmIChpbnNpZGVbYV1bYl0pIHsKICAgICAgICAgICAgZGlzdFthXVtiXSA9IDA7CiAgICAgICAgfQoKICAgICAgICBjbnRbYV1bYl0rKzsKCiAgICAgICAgZm9yIChhdXRvICZ4OmRpcikgewogICAgICAgICAgICBwaWkgbncgPSB4K2U7CiAgICAgICAgICAgIGlmICghY2hlY2sobncpKSBjb250aW51ZTsKICAgICAgICAgICAgaWYgKGRpc3RbbndbMF1dW253WzFdXSA+IGRpc3RbYV1bYl0rMSkgewogICAgICAgICAgICAgICAgZGlzdFtud1swXV1bbndbMV1dID0gZGlzdFthXVtiXSsxOwogICAgICAgICAgICAgICAgcHEucHVzaCh7LShkaXN0W2FdW2JdKzEpLCBud30pOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQoKICAgIC8vIGZpbmQgdGhlIG1heGltdW0gbnVtYmVyIG9mIHZpc2l0cwogICAgaW50IG14ID0gMDsKCiAgICBmb3IgKGludCBpPTA7aTxHUklEO2krKykgewogICAgICAgIGZvciAoaW50IGo9MDtqPEdSSUQ7aisrKSB7CiAgICAgICAgICAgIG14ID0gbWF4KG14LCBjbnRbaV1bal0pOwogICAgICAgIH0KICAgIH0KCiAgICBjb3V0PDxteDw8IlxuIjsKfQ==