"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let H = cin.getInt(), W = cin.getInt();
    let A = [0];
    for (let h = 0; h < H; h++) {
        A[h] = [0];
        let s = cin.getStr();
        for (let w = 0; w < W; w++) {
            A[h][w] = s[w] == '#' ? 1 : 0;
        }
    }
    let ans = 0, f = true;
    while (f) {
        ans++;
        f = false;
        for (let h = 0; h < H; h++) {
            for (let w = 0; w < W; w++) {
                if (A[h][w] == 1) {
                    A[h][w]++;
                    if (h > 0 && A[h - 1][w] == 0) A[h - 1][w]++;
                    if (h < H - 1 && A[h + 1][w] == 0) A[h + 1][w]++;
                    if (w > 0 && A[h][w - 1] == 0) A[h][w - 1]++;
                    if (w < W - 1 && A[h][w + 1] == 0) A[h][w + 1]++;
                } else if (A[h][w] == 0) f = true;
            }
        }
    }
    console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));
