#include<bits/stdc++.h>
using namespace std;
int n,m,ans,Map[201][201],vis[201][201],Max=-99999;
int qx[4]={0,0,-1,1};
int qy[4]={1,-1,0,0};
struct SB
{
	int x,y,z;
 } q[10000001];
void bfs(int I,int J)
{
	int head=1,tail=1;
	Max=-9999;
	memset(q,0,sizeof(q));
	memset(vis,0,sizeof(vis));
	q[1].x=I;
	q[1].y=J;
	q[1].z=0;
	while(head<=tail)
	{
		Max=max(Max,q[head].z);
		for(int i=0;i<=3;i++)
		{
			int x=q[head].x+qx[i];
			int y=q[head].y+qy[i];
			if(Map[x][y]==1&&vis[x][y]==0)
			{
				vis[x][y]=1;
				q[++tail].x=x;
				q[tail].y=y;
				q[tail].z=q[head].z+1;
			}
		}
		head++;
	}
}
int main()
{
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	scanf("%d%d",&n,&m);
	char ch;
	getchar();
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			scanf("%c",&ch);
			if(ch=='.') Map[i][j]=1;
			else Map[i][j]=0;
		}
		getchar();
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	if(Map[i][j]==1)
	{
		bfs(i,j);
		ans=max(ans,Max);
	}
	cout<<ans;
	return 0;
}
