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
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define INF 1e9
typedef long long ll;
typedef struct{
  int x,y,n;
}T;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
vector<vector<char> > mas;
queue<T> que;

int bfs(int H, int W){
  int max = 0;
  while(que.size()){
    T t = que.front();que.pop();
    int i;
    REP(i,4){
      int nx = t.x+dx[i], ny = t.y+dy[i], nn = t.n+1;
      if(nx >= 0 && nx < W && ny >= 0 && ny < H && mas[nx][ny] != '#'){
        mas[nx][ny] = '#';
        if(nn > max) max = nn;
        que.push({nx,ny,nn});
      }
    }
  }
  return max;
}

int main(void){
  int x,y,H,W;cin >> H >> W;
  mas = vector<vector<char> >(W,vector<char>(H));
  REP(y,H)REP(x,W){
    cin >> mas[x][y];
    if(mas[x][y] == '#')que.push({x,y,0});
  }
  cout << bfs(H,W) << endl;
  return 0;
}
