#include <bits/stdc++.h>
const int MOD = 1e9 + 7;
using namespace std;
char maze[20][20];
int h, w;
int search(int a, int b) {
  int dist1[4] = {1, 0, -1, 0};
  int dist2[4] = {0, 1, 0, -1};
  int reached[20][20];
  for (int i = 0; i < 20; i++) {
    for (int j = 0; j < 20; j++) {
      reached[i][j] = -1;
    }
  }
  queue<pair<pair<int, int>, int> > que;
  que.push(make_pair(make_pair(a, b), 0));
  while (!que.empty()) {
    int nowx = que.front().first.first, nowy = que.front().first.second,
        coun = que.front().second;
    cout << nowx << " " << nowy << endl;
    que.pop();
    for (int i = 0; i < 4; i++) {
      int x = nowx + dist1[i], y = nowy + dist2[i];
      if (x >= 0 && x < h) {
        if (y >= 0 && y < w) {
          if (maze[x][y] == '.') {
            if (reached[x][y] == -1) {
              reached[x][y] = coun + 1;
              que.push(make_pair(make_pair(x, y), coun + 1));
            }
          }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < 20; i++) {
    for (int j = 0; j < 20; j++) {
      ans = max(ans, reached[i][j]);
    }
  }
  return ans;
}
int main() {
  int ans = 0;
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> maze[i][j];
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (maze[i][j] == '.') {
        ans = max(search(i, j), ans);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
