#include #include using namespace std; int n,m,d[110][110]; int main(){ // freopen("f.in","r",stdin); scanf("%d%d",&n,&m); int i,j; char c; for(i = 1; i <= n; i++){ getchar(); for(j = 1; j <= m; j++){ c = getchar(); if(c == '&') d[i][j] = -1; } } if(d[1][1] == 0){ d[1][1] = 1; int last = 1; for(i = 1; i <= n; i++){ for(j = 1; j <= m; j++){ if(d[i][j] == -1 && d[i - 1][j] < 1 && j > last) break; else{ d[i][j] = d[i][j] == -1 ? -1 : max(d[i][j - 1],d[i - 1][j]) + 1; last = j; } } } } int maxim = 0; for(i = 1; i <= n; i++) for(j = 1; j <= m; j++){ maxim = max(d[i][j],maxim); } printf("%d\n",maxim); return 0; }