using System;
using System.Collections.Generic;
using System.Text;
using CompLib.Util;

public class Program
{
    private int H, W;
    private string[] A;
    private int[] Dx = new int[] {0, 1, -1, 0};
    private int[] Dy = new int[] {1, 0, 0, -1};

    public void Solve()
    {
        var sc = new Scanner();
        H = sc.NextInt();
        W = sc.NextInt();
        A = new string[H];
        for (int i = 0; i < H; i++)
        {
            A[i] = sc.Next();
        }

        int[,] dist = new int[H, W];
        var yq = new Queue<int>();
        var xq = new Queue<int>();
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (A[i][j] == '#')
                {
                    yq.Enqueue(i);
                    xq.Enqueue(j);
                }
                else
                {
                    dist[i, j] = int.MaxValue;
                }
            }
        }

        while (yq.Count > 0)
        {
            int yy = yq.Dequeue();
            int xx = xq.Dequeue();
            for (int i = 0; i < 4; i++)
            {
                int ny = yy + Dy[i];
                int nx = xx + Dx[i];
                if (ny < 0 || H <= ny) continue;
                if (nx < 0 || W <= nx) continue;
                if (dist[ny, nx] <= dist[yy, xx] + 1) continue;
                dist[ny, nx] = dist[yy, xx] + 1;
                yq.Enqueue(ny);
                xq.Enqueue(nx);
            }
        }

        int max = 0;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                max = Math.Max(max, dist[i,j]);
            }
        }

        Console.WriteLine(max);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 32392