import numpy as np

from scipy.ndimage.morphology import distance_transform_cdt



h, w = list(map(int, input().split()))

a = [eval(input()) for _ in range(h)]



a = np.array([[(ai[j] != "#") for j in range(w)] for ai in a])

d = distance_transform_cdt(a, metric="taxicab").max()

print(d)

import numpy as np

import copy



h, w = list(map(int, input().split()))

a = [eval(input()) for _ in range(h)]



a = np.array([[0 if (ai[j] == "#") else np.inf for j in range(w)] for ai in a])



for i in range(1, h):

    a[i] = np.minimum(a[i], a[i - 1] + 1)

for i in range(h - 2, -1, -1):

    a[i] = np.minimum(a[i], a[i + 1] + 1)

for i in range(1, w):

    a[:, i] = np.minimum(a[:, i], a[:, i - 1] + 1)

for i in range(w - 2, -1, -1):

    a[:, i] = np.minimum(a[:, i], a[:, i + 1] + 1)



print((int(a.max())))

import numpy as np
from scipy.ndimage.morphology import distance_transform_cdt

h, w = list(map(int, input().split()))
a = [eval(input()) for _ in range(h)]
a = np.array([[(ai[j] != "#") for j in range(w)] for ai in a])
d = distance_transform_cdt(a, metric="taxicab").max()
print(d)

import numpy as np
import copy

h, w = list(map(int, input().split()))
a = [eval(input()) for _ in range(h)]
a = np.array([[0 if (ai[j] == "#") else np.inf for j in range(w)] for ai in a])
for i in range(1, h):
    a[i] = np.minimum(a[i], a[i - 1] + 1)
for i in range(h - 2, -1, -1):
    a[i] = np.minimum(a[i], a[i + 1] + 1)
for i in range(1, w):
    a[:, i] = np.minimum(a[:, i], a[:, i - 1] + 1)
for i in range(w - 2, -1, -1):
    a[:, i] = np.minimum(a[:, i], a[:, i + 1] + 1)
print((int(a.max())))

-from scipy.ndimage.morphology import distance_transform_cdt +import copy -a = np.array([[(ai[j] != "#") for j in range(w)] for ai in a]) -d = distance_transform_cdt(a, metric="taxicab").max() -print(d) +a = np.array([[0 if (ai[j] == "#") else np.inf for j in range(w)] for ai in a]) +for i in range(1, h): +    a[i] = np.minimum(a[i], a[i - 1] + 1) +for i in range(h - 2, -1, -1): +    a[i] = np.minimum(a[i], a[i + 1] + 1) +for i in range(1, w): +    a[:, i] = np.minimum(a[:, i], a[:, i - 1] + 1) +for i in range(w - 2, -1, -1): +    a[:, i] = np.minimum(a[:, i], a[:, i + 1] + 1) +print((int(a.max())))