function main(input) {
  lines = input.split('\n')
  v = lines[0].split(' ').map((n) => parseInt(n));
  h = v[0];
  w = v[1];
  c = [];
  d = [];
  for (i = 1; i < h + 1; i++) {
    c.push(lines[i]);
    d.push([]);
  }
  q = [];
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (c[i][j] == '#') {
        q.push([i, j]);
        d[i][j] = 0;
      } else {
        d[i][j] = -1;
      }
    }
  }
  p = q.shift();
  max = 0;
  dx = [1, 0, -1, 0];
  dy = [0, 1, 0, -1];
  while (true) {
    xx = p[0];
    yy = p[1];
    for (i =0; i < 4; i++) {
      x = xx + dx[i];
      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]);
        count = d[xx][yy] + 1;
        if (max < count) {
          max = count;
        }
        d[x][y] = count;
      }
    }
    if (q.length == 0) {
      break;
    }
    p = q.shift();
  }
  console.log(max);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
