'use strict';
class Queue {
    constructor(size) {
        this.arr = new Array(size);
        this.head = this.tail = 0;
    }
    is_full() {
        return this.head == (this.tail + 1) % this.arr.length;
    }
    push(v) {
        if (this.is_full()) {
            this.arr.length *= 2;
        }
        this.arr[this.tail] = v;
        this.tail = (this.tail + 1) % this.arr.length;
    }
    is_empty() {
        return this.head == this.tail;
    }
    pop() {
        if (this.is_empty()) {
            throw -1;
        }
        let v = this.arr[this.head];
        this.head = (this.head + 1) % this.arr.length;
        return v;
    }
    maxsize() {
        return this.arr.length;
    }
}
function main(input) {
    let lines = input.split('\n');
    let v = lines[0].split(' ').map((n) => parseInt(n));
    let h = v[0];
    let w = v[1];
    let c = [];
    let d = [];
    for (let i = 1; i < h + 1; i++) {
        c.push(lines[i]);
        d.push([]);
    }
    let q = new Queue(1000000000);
    for (let i = 0; i < h; i++) {
        for (let j = 0; j < w; j++) {
            if (c[i][j] == '#') {
                q.push([i, j]);
                d[i][j] = 0;
            }
            else {
                d[i][j] = -1;
            }
        }
    }
    let p = q.pop();
    let max = 0;
    const dx = [1, 0, -1, 0];
    const dy = [0, 1, 0, -1];
    while (true) {
        const xx = p[0];
        const yy = p[1];
        for (let i = 0; i < 4; i++) {
            let x = xx + dx[i];
            let y = yy + dy[i];
            if (x < 0 || x > h - 1 || y < 0 || w - 1 < y || d[x][y] >= 0) {
                continue;
            }
            if (c[x][y] == '.') {
                q.push([x, y]);
                let count = d[xx][yy] + 1;
                if (max < count) {
                    max = count;
                }
                d[x][y] = count;
            }
        }
        if (q.is_empty()) {
            break;
        }
        p = q.pop();
    }
    console.log(max);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
