/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
ll n,m;
const int mm=25;
char a[mm][mm];
map<pair<ll,ll>,ll > vis;
ll dfs(ll x,ll y,ll x1,ll y1)
{
    if(x==x1 and y==y1)
        return 0;
    if(x>n-1 or y>m-1) 
        return INT_MAX;
    if(x<0 or y<0)
        return INT_MAX;
    if(vis[{x,y}]!=0)
        return INT_MAX;
    if(a[x][y]=='#')
        return INT_MAX;
    vis[{x,y}]=1;
    ll t1=dfs(x+1,y,x1,y1);
    ll t2=dfs(x-1,y,x1,y1);
    ll t3=dfs(x,y+1,x1,y1);
    ll t4=dfs(x,y-1,x1,y1);
    return 1+min({t1,t2,t3,t4});
}
int main()
{
    ll i,j,l,k;
    cin>>n>>m;
    rep(i,n)
        rep(j,m)
            cin>>a[i][j];
    ll ans=0;
    
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            for(k=i+1;k<n;k++)
            {
                for(l=j+1;l<m;l++)
                {
                    if(i==k and j==l)
                        continue;
                    if(a[i][j]=='#' or a[k][l]=='#')
                        continue;
                    vis.clear();
                    ll temp=dfs(i,j,k,l);
                    cout<<i<<" "<<j<<" "<<k<<" "<<l<<" "<<temp<<endl;
                    ans=max(temp,ans);
                    /*
                    if(temp>=ans)
                    {
                        ans=max(ans,temp);
                        //cout<<ans<<" "<<i<<" "<<j<<" "<<k<<" "<<l<<endl;
                    }
                    */
                }
            }
        }
    }
    cout<<ans<<endl;

}