import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}
	
	// ----------------------------------------
	
	int h = read.to!int;
	int w = read.to!int;
	
	bool[][] as = new bool[][](h, w);
	foreach(i; 0 .. h){
		string l = readln.chomp;
		foreach(j; 0 .. w) as[i][j] = (l[j] == '#');
	}
	
	int[][] bs = new int[][](h, w);
	foreach(i; 0 .. h) foreach(j; 0 .. w) if(as[i][j]) bs[i][j] = 0;
	
	int[2][] xs;
	foreach(i; 0 .. h) foreach(j; 0 .. w) if(as[i][j]) xs ~= [i, j];
	
	for(int iq = 0; iq < xs.length; iq ++){
		int i = xs[iq][0], j = xs[iq][1];
		if(i - 1 >= 0 && ! as[i - 1][j]) as[i - 1][j] = 1, bs[i - 1][j] = bs[i][j] + 1, xs ~= [i - 1, j];
		if(i + 1 <  h && ! as[i + 1][j]) as[i + 1][j] = 1, bs[i + 1][j] = bs[i][j] + 1, xs ~= [i + 1, j];
		if(j - 1 >= 0 && ! as[i][j - 1]) as[i][j - 1] = 1, bs[i][j - 1] = bs[i][j] + 1, xs ~= [i, j - 1];
		if(j + 1 <  w && ! as[i][j + 1]) as[i][j + 1] = 1, bs[i][j + 1] = bs[i][j] + 1, xs ~= [i, j + 1];
	}
	print!1("as:", as);
	print!1("bs:", bs);
	
	
	int ans = 0;
	foreach(i; 0 .. h) foreach(j; 0 .. w) ans = max(ans, bs[i][j]);
	
	ans.writeln;
}
