#include<iostream>

using namespace std;

int n, m, a[110][110], maxim, p, u;
char s[110][110];
struct qwert
{
	int x, y;
}c[100000],poz;
void citire()
{
	int i, j;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
			cin>>s[i][j];
	}
}
void coada()
{
	while(p<=u)
	{
		poz=c[p];
		p++;
		if(a[poz.x+1][poz.y]==0&&s[poz.x+1][poz.y]=='.')
		{
			u++;
			a[poz.x+1][poz.y]=a[poz.x][poz.y]+1;
			c[u].x=poz.x+1;
			c[u].y=poz.y;
		}
		if(a[poz.x][poz.y+1]==0&&s[poz.x][poz.y+1]=='.')
		{
			u++;
			a[poz.x][poz.y+1]=a[poz.x][poz.y]+1;
			c[u].x=poz.x;
			c[u].y=poz.y+1;
		}
		if(a[poz.x][poz.y]>maxim)
			maxim=a[poz.x][poz.y];
	}
}
int main()
{
	citire();
	p=u=1;
	c[u].x=1;
	c[u].y=1;
	a[1][1]=1;
	maxim=1;
	coada();
	cout<<maxim;
	return 0;
}