#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
struct node {
  int x, y, step;
};
struct node2 {
  int x, y;
} a[444];
char d[22][22];
int n, m;
int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
bool judge(int x, int y) {
  if (x >= n || y >= m || x < 0 || y < 0 || d[x][y] == '#')
    return false;
  else
    return true;
}
int bfs(int x, int y, int fx, int fy) {
  queue<node> q;
  node a;
  a.x = x;
  a.y = y;
  a.step = 0;
  q.push(a);
  while (!q.empty()) {
    node now = q.front();
    q.pop();
    printf("%d %d %d\n", now.x, now.y, now.step);
    if (now.x == fx && now.y == fy) return now.step;
    for (int i = 0; i < 4; i++) {
      node ne;
      ne.x = now.x + dx[i];
      ne.y = now.y + dy[i];
      ne.step = now.step + 1;
      if (judge(ne.x, ne.y)) {
        q.push(ne);
      }
    }
  }
  return 0;
}
int main() {
  cin >> n >> m;
  int k = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> d[i][j];
      if (d[i][j] != '#') {
        a[++k].x = i;
        a[k].y = j;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) {
      if (i == j) continue;
      ans = max(ans, bfs(a[i].x, a[i].y, a[j].x, a[j].y));
    }
  }
  cout << ans << endl;
}
