#include using namespace std; const int N=3010; int n,m,ans,dis[N][N]; string a[N]; queue q; signed main(){ // freopen("1.in","r",stdin); ios::sync_with_stdio(0); cin>>n>>m; for(int i=0;i<=m+1;i++){ a[0]+='.'; a[n+1]+='.'; } for(int i=1;i<=n;i++){ cin>>a[i]; a[i]="."+a[i]+"."; } // cerr<<"input done\n"; 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*10000+j); } } while(!q.empty()){ int now=q.front(),i=now/10000,j=now%10000; q.pop(); // cout<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*10000+nj); } } } cout<