#include <bits/stdc++.h>
using namespace std;

vector<vector<char>> S;
int H,W;

int bfs(int Sx, int Sy){
  vector<int> cost(H*W,-1);
  queue<int> que;
  cost[Sy*W+Sx] = 0;
  que.push(Sy*W+Sx);
  int dx[4] = {-1,0,1,0};
  int dy[4] = {0,-1,0,1};
  while(!que.empty()){
    int v = que.front();
    que.pop();
    int x = v%W;
    int y = floor(v/W);
    for(int i = 0; i < 4; i++){
      if(x+dx[i] >= 0 && x+dx[i] < W && y+dy[i] >= 0 && y+dy[i] < H){
        cout << x << " " << y << " " << x+dx[i] << " " << y+dy[i] << endl;
        if(cost[nv] == -1 && S[y+dy[i]][x+dx[i]] == '.'){
          que.push(nv);
          cost[nv] = cost[v]+1;
        }
      }
    }
  }
  int m = 0;
  for(auto c : cost){
    m = max(c,m);
  }
  return m;
}

int main(){
  cin >> H >> W;
  S.assign(H,vector<char>(W));
  for(int y = 0; y < H; y++){
    for(int x = 0; x < W; x++){
      cin >> S[y][x];
    }
  }
  int m = 0;
  for(int Sy = 0; Sy < H; Sy++){
    for(int Sx = 0; Sx < W; Sx++){
      if(S[Sy][Sx] == '#') break;
      m = max(m,bfs(Sx,Sy));
    }
  }
  cout << m << endl;
}
