#include using namespace std; const int N=3010; int n,m,ans,dis[N][N]; string a[N]; queue q; signed main(){ ios::sync_with_stdio(0); cin>>n>>m; for(int i=0;i<=m+1;i++){ a[0][i]='.'; a[n+1][i]='.'; } for(int i=1;i<=n;i++){ cin>>a[i]; a[i]="."+a[i]+"."; } memset(dis,0x3f,sizeof(dis)); for(int i=0;i<=n+1;i++){ for(int j=0;j<=m+1;j++){ if(a[i][j]=='.') dis[i][j]=0,q.push(i*N+j); } } while(!q.empty()){ int now=q.front(),i=now/N,j=now%N; q.pop(); for(int nxt=0;nxt<=8;nxt++){ int ni=i+(nxt/3-1),nj=j+(nxt%3-1); if(ni<0||ni>n+1||nj<0||nj>m+1) continue; if(dis[ni][nj]>dis[i][j]+1){ dis[ni][nj]=dis[i][j]+1; ans=max(ans,dis[ni][nj]); q.push(ni*N+nj); } } } cout<