#include int max,i,j,n,m,a[1000][1000]; char c; int main() { //freopen("run.in","r",stdin); //freopen("run.out","w",stdout); scanf("%d%d\n",&n,&m); for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { scanf("%c",&c); if(c=='&') a[i][j]=-1; } scanf("\n"); } for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { if(a[i][j]!=-1) { if(a[i-1][j]+1>a[i][j]) a[i][j]=a[i-1][j]+1; if(a[i][j-1]+1>a[i][j]) a[i][j]=a[i][j-1]+1; } } } for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { if(max