#include <algorithm>
#include <iostream>
#include <vector>
#include <set>

typedef long long ll;
using namespace std;
int n;
vector<vector<int>> a;
set<int> ids;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main() {
    cin >> n;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        a.emplace_back(vector<int>{x, y, i});
    }
    rep(k, 2) {
        sort(a.begin(), a.end());
        rep(i, 2) {
            ids.emplace(a[i][2]);
            ids.emplace(a[n - 1 - i][2]);
        }
        for (auto& v : a)swap(v[0], v[1]);
    }
    vector<pair<int, int>> b;
    for (auto v : a) {
        if (ids.count(v[2]) > 0)b.emplace_back(v[0], v[1]);
    }
    vector<ll> d;
    for (int i = 0; i < (int)b.size(); i++) {
        for (int j = i + 1; j < (int)b.size(); j++) {
            d.emplace_back(max(abs(b[i].first - b[j].first), abs(b[i].second - b[j].second)));
        }
    }
    sort(d.begin(), d.end());
    cout << d[d.size() - 2] << endl;
    return 0;
}
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <iostream>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    int ans = 0;
    string S[100];
    cin >> H >> W;
    REP(i, H)
    cin >> S[i];

    REP(h, H){
        REP(w, W){
            if (S[h][w]=='.'){
                if ( w+1<W && S[h][w+1]=='.' )
                    ans++;
                if (h+1<H && S[h+1][w]=='.')
                    ans++;
            }
        }
    }
    cout << ans << endl;
}