import std.stdio, std.conv, std.string, std.algorithm, std.array, std.range;

const long INF = 9999999999;

void main() {
    long h, w;
    char[][] field = [];

    readf("%d %d\n", &h, &w);
    foreach (_; 0..h) {
        field ~= readln.strip.dup;
    }


    auto dists = new long[][](h, w);
    long[] xs = [];
    long[] ys = [];
    foreach (y; 0..h) {
        foreach (x; 0..w) {
            if (field[y][x] == '#') {
                dists[y][x] = 0;
                xs ~= x;
                ys ~= y;
            }
            else {
                dists[y][x] = INF;
            }
        }
    }

    while (xs.length > 0) {
        long x = xs.front;
        long y = ys.front;
        xs = xs[1..$];
        ys = ys[1..$];

        long[] dx = [0, -1, 1, 0];
        long[] dy = [-1, 0, 0, 1];

        foreach (i; 0..dx.length) {
            long x2 = x + dx[i];
            long y2 = y + dy[i];
            if (0 <= x2 && x2 < w && 0 <= y2 && y2 < h) {
                if (dists[y2][x2] > dists[y][x]+1) {
                    dists[y2][x2] = dists[y][x] + 1;
                    xs ~= x2;
                    ys ~= y2;
                }
            }
        }
    }

    long ans = 0;
    foreach (y; 0..h) {
        foreach (x; 0..w) {
            if (ans < dists[y][x]) {
                ans = dists[y][x];
            }
        }
    }
    writeln(ans);
}
