using System;
using static System.Console;
using System.Text;
using System.Linq;
using static System.Math;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Program
{
    public static cp alg;
    public static int h;
    public static int w;
    public static string[] A;
    public static List<int[]> V;
    static void Main(string[] args)
    {
        alg = new cp();
        var hw = alg.inputSplitInt();
        h = hw[0];
        w = hw[1];
        A = alg.inputLinesString(h);
        var V = new bool[h, w];
        var cost = new int[h, w];
        for (int a = 0; a < h; a++)
        {
            for (int b = 0; b < w; b++)
            {
                V[a, b] = false;
            }
        }
        var que = new Queue<int[]>();
        //最初の#をキューに入れる
        int count = 0;
        for (int a = 0; a < h; a++)
        {
            for (int b = 0; b < w; b++)
            {
                if (A[a][b] == '#')
                {
                    que.Enqueue(new int[2] { b, a });
                    V[a, b] = true;
                    cost[a, b] = 0;
                }
            }
        }
        
        while (que.Count > 0)
        {

            var now = que.Dequeue();
            var x = now[0];
            var y = now[1];
            
            var dx = new int[] { -1, 0, 1, 0 };
            var dy = new int[] { 0, -1, 0, 1 };
            for (int a = 0; a < 4; a++)
            {
                if (x + dx[a] < 0 || x + dx[a] >= w || y + dy[a] < 0 || y + dy[a] >= h || V[y + dy[a], x + dx[a]]) continue;
                que.Enqueue(new int[] { x + dx[a], y + dy[a] });
                V[y + dy[a], x + dx[a]] = true;
                cost[y + dy[a], x + dx[a]] = cost[y, x] + 1;
                count = Math.Max(count, cost[y, x] + 1);
            }
        }
        WriteLine(count);
    }
}

class cp
{

    public cp()
    {
    }
    public int GCD(int a, int b)
    {
        return a % b == 0 ? b : GCD(b, a % b);
    }
    public int LCM(int a, int b)
    {
        return a * b / GCD(a, b);
    }
    public int countChar(string s, string key)
    {
        return s.Length - s.Replace(key, "").Length;
    }
    public string Yn(bool f)
    {
        if (f)
        {
            return "Yes";
        }
        else
        {
            return "No";
        }
    }
    public string YN(bool f)
    {
        if (f)
        {
            return "YES";
        }
        else
        {
            return "NO";
        }
    }
    public string yn(bool f)
    {
        if (f)
        {
            return "yes";
        }
        else
        {
            return "no";
        }
    }
    public void inputSkip()
    {
        ReadLine();
        return;
    }
    public string inputString()
    {
        return ReadLine();
    }
    public string[] inputSplitString()
    {
        return ReadLine().Split();
    }
    public string[] inputLinesString(int len)
    {
        var arr = new string[len];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine();
        }
        return arr;
    }
    public string[][] inputJaggedArrayString(int len)
    {
        var arr = new string[len][];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine().Split();
        }
        return arr;
    }
    public int inputInt()
    {
        return int.Parse(ReadLine());
    }
    public int[] inputSplitInt()
    {
        return ReadLine().Split().Select(i => int.Parse(i)).ToArray();
    }
    public int[] inputLinesInt(int len)
    {
        var arr = new int[len];
        for (int a = 0; a < len; a++)
        {
            arr[a] = int.Parse(ReadLine());
        }
        return arr;
    }
    public int[][] inputJaggedArrayInt(int len)
    {
        var arr = new int[len][];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        }
        return arr;
    }
    public long inputLong()
    {
        return long.Parse(ReadLine());
    }
    public long[] inputSplitLong()
    {
        return ReadLine().Split().Select(i => long.Parse(i)).ToArray();
    }
    public long[] inputLinesLong(int len)
    {
        var arr = new long[len];
        for (int a = 0; a < len; a++)
        {
            arr[a] = long.Parse(ReadLine());
        }
        return arr;
    }
    public long[][] inputJaggedArrayLong(int len)
    {
        var arr = new long[len][];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine().Split().Select(i => long.Parse(i)).ToArray();
        }
        return arr;
    }
    public double inputDouble()
    {
        return double.Parse(ReadLine());
    }
    public double[] inputSplitDouble()
    {
        return ReadLine().Split().Select(i => double.Parse(i)).ToArray();
    }
    public double[] inputLinesDouble(int len)
    {
        var arr = new double[len];
        for (int a = 0; a < len; a++)
        {
            arr[a] = double.Parse(ReadLine());
        }
        return arr;
    }
    public double[][] inputJaggedArrayDouble(int len)
    {
        var arr = new double[len][];
        for (int a = 0; a < len; a++)
        {
            arr[a] = ReadLine().Split().Select(i => double.Parse(i)).ToArray();
        }
        return arr;
    }
}

Measured memory_bytes: 70236