#include #include using namespace std; #define range(i,a,b) for(int i=(a); i < (b); i++) #define rep(i,n) range(i,0,n) char S[3002][3002]; int VD[3002][3002],HD[3002][3002]; int main(){ int H,W,MAX,ans = 0; scanf("%d %d",&H,&W); rep(i,H) scanf("%s",S[i]); MAX = max(H,W); rep(i,H+2) rep(j,W+2){ if (i<1 || i>H || j<1 || j>W) VD[i][j] = HD[j][i] = 0; else VD[i][j] = HD[j][i] = (S[i-1][j-1] == '.' ? 0 : MAX); } range(i,1,H+1) range(j,1,W+1) rep(k,3){ VD[i][j] = min(VD[i][j],VD[i-1][j-1+k]+1); VD[H+1-i][j] = min(VD[H+1-i][j],VD[H+2-i][j-1+k]+1); } range(j,1,W+1) range(i,1,H+1) rep(k,3){ HD[j][i] = min(HD[j][i],HD[j-1][i-1+k]+1); HD[W+1-j][i] = min(HD[W+1-j][i],HD[W+2-j][i-1+k]+1); } range(i,1,H+1) range(j,1,W+1){ ans = max(ans,min(VD[i][j],HD[j][i])); } printf("%d\n",ans); return 0; }