/*
  AUTHOR:SOURABH
  CREATED:10:01:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

string s[20];
bool vis[20][20];
ll sum[20][20];
ll n,m,x1,yy,x2,y2;

void dfs(ll i,ll j)
{
    vis[i][j]=1;
    if(i+1<n && s[i+1][j]=='.' && !vis[i+1][j])
    {sum[i+1][j]=sum[i][j]+1;dfs(i+1,j);}
    if(j+1<m && s[i][j+1]=='.' && !vis[i][j+1])
    {sum[i][j+1]=sum[i][j]+1;dfs(i,j+1);}
    if(i-1>=0 && s[i-1][j]=='.' && !vis[i-1][j])
    {sum[i-1][j]=sum[i][j]+1;dfs(i-1,j);}
    if(j-1>=0 && s[i][j-1]=='.' && !vis[i][j-1])
    {sum[i][j-1]=sum[i][j]+1;dfs(i,j-1);}
    //cout<<i<<" "<<j<<" "<<sum[i][j]<<endl;
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("in.txt","r",stdin);
    //freopen(2 "out.txt","w",stdout);

    ll k,i,j,ma,o;
    cin>>n>>m;
    vector<pll> ans;
    fn(i,n)
    {
        cin>>s[i];
        fn(j,m)
        {
            if(s[i][j]=='.')
            ans.pb({i,j});
        }
    }
    k=ans.size();
    ma=0;
    fn(i,k)
    {
        x1=ans[i].fi;
        yy=ans[i].se;
        memset(vis,0,sizeof(vis));
        memset(sum,0,sizeof(sum));
        dfs(x1,yy);
        /*cout<<x1<<" "<<y1<<endl;
        fn(o,n)
        {
            fn(j,m)
            cout<<sum[o][j]<<" ";
            cout<<endl;
        }
        cout<<endl;*/
        fs(j,i+1,k)
        {
            x2=ans[j].fi;
            y2=ans[j].se;
            ma=max(ma,sum[x2][y2]);
        }
    }
    cout<<ma;
    return 0;
}







