local h,w=io.read("n","n","l")
local a={}
local dist={}
for i=1,h do
    local input=io.read()
    a[i]={}
    dist[i]={}
    for j=1,w do
        a[i][j]=input:byte(j)
        dist[i][j]=-1
    end
end

local que={}
for i=1,h do
    for j=1,w do
        if a[i][j]==35 then
            dist[i][j]=0
            table.insert(que,{i,j})
        end
    end
end

local di={1,0,-1,0}
local dj={0,1,0,-1}
local l=1
while que[l] do
    local i=que[l][1]
    local j=que[l][2]
    for k=1,4 do
        local ni=i+di[k]
        local nj=j+dj[k]
        if dist[ni] and dist[ni][nj] and dist[ni][nj]==-1 then
            dist[ni][nj]=dist[i][j]+1
            table.insert(que,{ni,nj})
        end 
    end
    l=l+1
end

local max=0
for i=1,h do
    for j=1,w do
        max=math.max(max,dist[i][j])
    end
end
print(max)