#include #include using namespace std; int n,m; char d[101][101]; void read() { int i,j; scanf("%d%d",&n,&m); for(i = 0; i < n; i++){ getchar(); for(j = 0; j < m; j++){ char c = getchar(); d[i][j] = c; } } } int solve(){ int best = -1,max = 0,last = -1,li = 0; int i = 0,j = 0; while(/*j < m &&*/ i < n){ if(max > best) best = max; if(d[i][j] != '&') max ++,j ++; if(i != li){ int cj = j - 1; while(cj >= 0 && d[i][cj] != '&') cj--; if(cj > last) last = cj; } if(j == m || d[i][j] == '&') { if(max > best) best = max; i++; -- j; // max ++; while(d[i][j] == '&' && j > last){ --j,--max; if(i > 0 && d[i - 1][j] == '&') return best; } if(j < last) return best; } if(j < 0) return best; li = i; } return best; } int main() { // freopen("f.in","r",stdin); read(); printf("%d\n",solve()); return 0; }