#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";
}