#include int n,m, coada[10000][2]; char a[101][101], aux; int b[101][101]; int main() { int p,u , maxim = 0, x, y, i , j; scanf("%d", &n); scanf("%d", &m); for(i = 0; i < n; ++i) { scanf("%s", &a[i]); } p = u = 0; coada[0][0] = 0; coada[0][1] = 0; b[0][0] = 1; while(p <= u) { 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]; } 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]; } ++p; } printf("%d", maxim); }