import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(string[] g) {
    int rows = cast(int)g.length;
    int cols = cast(int)g[0].length;
    int[][] bs;
    foreach (r; 0..rows) foreach (c; 0..cols) {
        if (g[r][c] == '#') bs ~= [r, c];
    }

    int ans = 0;
    foreach (r; 0..rows) foreach (c; 0..cols) {
        if (g[r][c] == '.') {
            int d = int.max;
            foreach (b; bs) {
                int m = abs(r - b[0]) + abs(c - b[1]);
                d = min(d, m);
            }
            ans = max(ans, d);
        }
    }
    return ans;
}

void main() {
    int h, w; scan(h, w);
    string[] g;
    foreach (_; 0..h) g ~= read!string;
    writeln(calc(g));
}
