
"use strict";

process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    const tokens = input[0].split(' ').map(function(value) { return parseInt(value, 10); });
    const h = tokens[0];
    const w = tokens[1];

    let a = new Array(h);
    for (let i = 0; i < h; i++) {
        a[i] = input[i + 1].split('');
    }

    let distanceMap = new Array(h);
    let blackCells = [];
    for (let i = 0; i < h; i++) {
        distanceMap[i] = new Array(w);
        for (let j = 0; j < w; j++) {
            if (a[i][j] === "#") {
                distanceMap[i][j] = 0;
                blackCells.push({x: i, y: j, distance: 0});
            } else {
                distanceMap[i][j] = Number.MAX_SAFE_INTEGER;
            }
        }
    }

    while (blackCells.length > 0) {
        const blackCell = blackCells.shift();
        changeWhite(h, w, distanceMap, blackCells, blackCell.x, blackCell.y, blackCell.distance);
    }


    let ans = 0;
    for (let i = 0; i < h; i++) {
        for (let j = 0; j < w; j++) {
            if (ans < distanceMap[i][j]) {
                ans = distanceMap[i][j];
            }
        }
    }

    console.log(ans);

    return 0;
}

function changeWhite(h, w, distanceMap, blackCells, i, j, distance) {

    if (i - 1 >= 0 && distanceMap[i - 1][j] > distance + 1) {
        distanceMap[i - 1][j] = distance + 1;
        blackCells.push({x: i - 1, y: j, distance: distance + 1});
    }

    if (i + 1 < h && distanceMap[i + 1][j] > distance + 1) {
        distanceMap[i + 1][j] = distance + 1;
        blackCells.push({x: i + 1, y: j, distance: distance + 1});
    }
    
    if (j - 1 >= 0 && distanceMap[i][j - 1] > distance + 1) {
        distanceMap[i][j - 1] = distance + 1;
        blackCells.push({x: i, y: j - 1, distance: distance + 1});
    }

    if (j + 1 < w && distanceMap[i][j + 1] > distance + 1) {
        distanceMap[i][j + 1] = distance + 1;
        blackCells.push({x: i, y: j + 1, distance: distance + 1});
    }
}