"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let H = cin.getInt(), W = cin.getInt();
    let A = new Array(H).fill(0).map(() => new Array(W).fill(0));
    Array.prototype.enq = function(n, y, x) { this.push({n:n, y:y, x:x}); return n } 
    Array.prototype.deq = function() { return this.shift() } 
    let Q = [];
    for (let h = 0; h < H; h++) {
        let s = cin.getStr();
        A[h] = s.split('').map((v, w) => v == '#' ? Q.enq(0, h, w) + 1 : 0);
    }
    let ans = 0;
    while (Q.length > 0) {
        let q = Q.deq();
        ans = q.n;
        if (q.y > 0 &&     A[q.y - 1][q.x] == 0) A[q.y - 1][q.x] = Q.enq(q.n + 1, q.y - 1, q.x);
        if (q.y < H - 1 && A[q.y + 1][q.x] == 0) A[q.y + 1][q.x] = Q.enq(q.n + 1, q.y + 1, q.x);
        if (q.x > 0 &&     A[q.y][q.x - 1] == 0) A[q.y][q.x - 1] = Q.enq(q.n + 1, q.y, q.x - 1);
        if (q.x < W - 1 && A[q.y][q.x + 1] == 0) A[q.y][q.x + 1] = Q.enq(q.n + 1, q.y, q.x + 1);
    }
    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"));
