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.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt(), W = sc.nextInt();
        int[][] A = new int[H][W];
        Queue Q = new Queue();
        for (int h = 0; h < H; h++) {
            String s = sc.next();
            for (int w = 0; w < W; w++) {
                int b = A[h][w] = s.charAt(w) == '#' ? 1 : 0;
                if (b == 1) Q.add(0, h, w);
            }
        }
        int ans = 0;
        while (!Q.isEmpty()) {
            Que q = Q.poll();
            ans = q.n;
            if (q.y > 0 &&     A[q.y - 1][q.x] == 0) A[q.y - 1][q.x] = Q.add(q.n + 1, q.y - 1, q.x);
            if (q.y < H - 1 && A[q.y + 1][q.x] == 0) A[q.y + 1][q.x] = Q.add(q.n + 1, q.y + 1, q.x);
            if (q.x > 0 &&     A[q.y][q.x - 1] == 0) A[q.y][q.x - 1] = Q.add(q.n + 1, q.y, q.x - 1);
            if (q.x < W - 1 && A[q.y][q.x + 1] == 0) A[q.y][q.x + 1] = Q.add(q.n + 1, q.y, q.x + 1);
        }
        System.out.println(ans);
        sc.close();
    }
}
class Que {
    int n, x, y;
    Que(int n, int y, int x) {
        this.n = n;
        this.x = x;
        this.y = y;
    }
}
class Queue {
    Deque<Que> Q;
    Queue() {
        Q = new ArrayDeque<>();
    }
    int add(int n, int y, int x) {
        Q.add(new Que(n, y, x));
        return n;
    }
    boolean isEmpty() { return Q.isEmpty(); }
    Que poll() { return Q.poll(); }
}
