#include int b[101][101], n, m, maxim, coada[20000][2], p, u; char a[101][101]; int main() { int j, x, y; scanf("%d", &n); scanf("%d", &m); for(j = 0; j < n; ++j) { scanf("%s", a[j]); } if(a[0][0] == '&') { printf("0"); return 0; } coada[0][0] = 0; coada[0][1] = 0; p = u = 0; maxim = 1; b[0][0] = 1; while(p <= u) { x = coada[p][0] + 1; y = coada[p][1]; if(x < n && y < m && a[x][y] == '.' && b[x][y] == 0) { coada[++u][0] = x; coada[u][1] = y; b[x][y] = b[coada[p][0]][coada[p][1]] + 1; if(b[x][y] > maxim) maxim = b[x][y]; } x = coada[p][0]; y = coada[p][1] + 1; if(x < n && y < m && a[x][y] == '.' && b[x][y] == 0) { coada[++u][0] = x; coada[u][1] = y; b[x][y] = b[coada[p][0]][coada[p][1]] + 1; if(b[x][y] > maxim) maxim = b[x][y]; } ++p; } printf("%d", maxim); return 0; }