#include<iostream>
#include<cstdlib>
using namespace std;
int a[1000000];
int b[1000000];
int main()
{
	char matrix[1010][1010];
	long long baris,k,i,j,z,counter,maks,min;
	
	cin >>baris >>k;
	counter = 0;
	for(i=0;i<baris;i++)
	{
		for(j=0;j<k;j++)
		{
			cin >> matrix[i][j];
			if(matrix[i][j]=='#')
			{
				a[counter] = i;
				b[counter] = j;
				counter++;
			}
		}
	}
	maks = 0;
	for(i=0;i<baris;i++)
	{
		for(j=0;j<k;j++)
		{
			if(matrix[i][j] == '.')
			{min = 1000000000;
				for(z = 0;z<counter;z++)
				{
					if (min > abs(i-a[z]) + abs(j-b[z]))
					{
						min = abs(i-a[z]) + abs(j-b[z]);
					}
				}
				if(maks < min)
				{
					maks = min;
				}
			}
		}
	}
	cout << maks << endl;
}