You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. HW characters from A_{11} to A_{HW} represent the colors of the squares. A_{ij} is `#` if the square at the i-th row from the top and the j-th column from the left is black, and A_{ij} is `.` if that square is white.

We will repeatedly perform the following operation until all the squares are black:

* Every white square that shares a side with a black square, becomes black.



Find the number of operations that will be performed. The initial grid has at least one black square.

Constraints

* 1 \leq H,W \leq 1000
* A_{ij} is `#` or `.`.
* The given grid has at least one black square.

Input

Input is given from Standard Input in the following format:


H W
A_{11}A_{12}...A_{1W}
:
A_{H1}A_{H2}...A_{HW}


Output

Print the number of operations that will be performed.

Examples

Input

3 3
...
.#.
...


Output

2


Input

6 6
..#..#
......
..#..
......
.#....
....#.


Output

3
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int H = sc.nextInt();
		int W = sc.nextInt();

		Deque<int[]> q = new ArrayDeque<>();
		
		int[][] A = new int[H+2][W+2];
		for(int i=0;i<A.length;i++) {
			Arrays.fill(A[i], -1);
		}
		for(int i=1;i<=H;i++) {
			String s = sc.next();
			for(int j=1;j<=W;j++) {
				if(s.charAt(j-1) == '#') {
					q.add(new int[] {i,j, 0});
				}
			}
		}
		
		sc.close();
		
		while(!q.isEmpty()) {
			int[] yx = q.poll();
			int y = yx[0];
			int x = yx[1];
			int c = yx[2];

			if(y == 0 || y == H+1 || x==0 || x == W+1) {
				continue;
			}
			if(A[y][x] >= 0) {
				//すでに処理済み。
				continue;
			}
			
			A[y][x] = c;
			if(A[y+1][x] == -1) q.add(new int[] {y+1, x, c+1});
			if(A[y-1][x] == -1) q.add(new int[] {y-1, x, c+1});
			if(A[y][x+1] == -1) q.add(new int[] {y, x+1, c+1});
			if(A[y][x-1] == -1) q.add(new int[] {y, x-1, c+1});
			
		}
		
		int ans = 0;
		for(int i=1;i<=H;i++) {
			for(int j=1;j<=W;j++) {
				ans = Math.max(ans, A[i][j]);
			}
		}
		
		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
	
	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray1origin(Scanner sc, int n) {
		int[] result = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}
