#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll h,w;
    cin >> h >> w;

    vector<string> g;
    string pad = "";
    for(int i = 0; i < w+2; i++){
        pad += '#';
    }
    g.push_back(pad);
    for(int i = 0; i < h; i++){
        string x = "#";
        string str;
        cin >> str;
        x += str;
        x += '#';
        g.push_back(x);
    }
    g.push_back(pad);

    vector<vector<ll>> gx(h+2,vector<ll>(w+2,0)),gy(h+2,vector<ll>(w+2,0));

    for(int i = 0; i < h+2; i++){
        for(int j = 0; j < w+2; j++){
            if(g[i][j] == '#'){
                gx[i][j] = j;
                gy[i][j] = i;
            }
        }
    }


    vector<vector<ll>> gu(h+2,vector<ll>(w+2,0)),gn(h+2,vector<ll>(w+2,0)),gr(h+2,vector<ll>(w+2,0)),gl(h+2,vector<ll>(w+2,0));

    for(int i = 0; i < h+2; i++){
        for(int j = 0; j < w+2; j++){
            gl[i][j] = gx[i][j];
            if(j > 0){
                gl[i][j] = max(gl[i][j],gl[i][j-1]);
            }
        }
    }

    for(int i = 0; i < w+2; i++){
        for(int j = 0; j < h+2; j++){
            gu[j][i] = gy[j][i];
            if(j > 0){
                gu[j][i] = max(gu[j][i],gu[j-1][i]);
            }
        }
    }

    

    for(int i = 0; i < h+2; i++){
        for(int j = w+1; j >= 0; j--){
            gr[i][j] = gx[i][j];
            if(gr[i][j] == 0){
                gr[i][j] = INF;
            }
            if(j <= w){
                gr[i][j] = min(gr[i][j],gr[i][j+1]);
            }
        }
    }

    for(int i = 0; i < w+2; i++){
        for(int j = h+1; j >= 0; j--){
            gn[j][i] = gy[j][i];
            if(gn[j][i] == 0){
                gn[j][i] = INF;
            }
            if(j <= h){
                gn[j][i] = min(gn[j][i],gn[j+1][i]);
            }
        }
    }
    /*

    for(int i = 1;  i < h+1; i++){
        for(int j = 1; j < w+1; j++){
            cerr << gl[i][j] << " ";
        }
        cerr << endl;
    }
    cerr << endl;

    for(int i = 1;  i < h+1; i++){
        for(int j = 1; j < w+1; j++){
            cerr << gr[i][j] << " ";
        }
        cerr << endl;
    }
    cerr << endl;

    for(int i = 1;  i < h+1; i++){
        for(int j = 1; j < w+1; j++){
            cerr << gu[i][j] << " ";
        }
        cerr << endl;
    }
    cerr << endl;

    for(int i = 1;  i < h+1; i++){
        for(int j = 1; j < w+1; j++){
            cerr << gn[i][j] << " ";
        }
        cerr << endl;
    }
    cerr << endl;*/


    ll ans = 0;
    for(int i = 0; i < h+2; i++){
        for(int j = 0; j < w+2; j++){
            if(g[i][j] != '#'){
                ans = max(ans,abs(gu[i][j] - (ll)i) + abs(gn[i][j] - (ll)i) + abs(gl[i][j] - (ll)j) + abs(gr[i][j] - (ll)j) - 3LL);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 196608