Problem: 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

Solution (in JAVA):

Solution:
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        boolean[][] map = new boolean[h][w];
        Deque<Point> q = new ArrayDeque<Point>();
        for(int i = 0; i < h; i++){
            String s = sc.next();
            int j = 0;
            for(char c : s.toCharArray()){
                if(c == '#'){
                    map[i][j] = true;
                    q.add(new Point(0,j,i));
                }
                j++;
            }
        }
        int ans = 0;
        int[] gx = {-1,0,0,1};
        int[] gy = {0,-1,1,0}; 
        while(q.size() > 0){
            Point p = q.poll();
            int cnt = p.cnt;
            int x = p.x;
            int y = p.y;
            for(int i = 0; i < 4; i++){
                int nx = x + gx[i];
                int ny = y + gy[i];
                if(check(nx,ny,w,h,map)){
                    map[ny][nx] = true;
                    q.add(new Point(cnt+1,nx,ny));
                }
            }
            ans = Math.max(ans,cnt);
        }
        System.out.println(ans);
    }
    
    public static boolean check(int x, int y, int w, int h, boolean[][] map){
        return (x >= 0 && x < w && y >= 0 && y < h && !map[y][x]);
    }
}

class Point{
    int cnt,x,y;
    public Point(int cnt, int x, int y){
        this.cnt = cnt;
        this.x = x;
        this.y = y;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}