#include <bits/stdc++.h>
using namespace std;
struct Node {
  vector<int> next;
  int depth = 0;
  int visited = 0;
  int parent;
  int type;
};
int get_path(vector<Node>& node, int start_idx) {
  queue<int> que;
  vector<int> depth_array(node.size());
  for (size_t i = 0; i < node.size(); i++) {
    node[i].visited = 0;
  }
  que.push(start_idx);
  node[start_idx].depth = 0;
  node[start_idx].parent = start_idx;
  while (!que.empty()) {
    int index = que.front();
    que.pop();
    node[index].visited = 1;
    node[index].depth = node[node[index].parent].depth + 1;
    depth_array[index] = node[index].depth;
    for (int i = 0; i < int(node[index].next.size()); i++) {
      int next_idx = node[index].next[i];
      if (node[next_idx].visited == 0 && node[next_idx].type == 0) {
        node[next_idx].parent = index;
        que.push(next_idx);
      }
    }
  }
  int max = *max_element(depth_array.begin(), depth_array.end());
  printf("%d %d\n", start_idx, max);
  return max - 1;
}
int main(int argc, char* argv[]) {
  int H, W;
  scanf("%d %d", &H, &W);
  vector<Node> node(H * W);
  char S[H][W];
  char input[W];
  for (int i = 0; i < H; i++) {
    scanf("%s", input);
    for (int j = 0; j < W; j++) {
      S[i][j] = input[j];
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      Node n;
      if (S[i][j] != '.') {
        n.type = 1;
      } else {
        n.type = 0;
        if (S[i + 1][j] == '.' && i + 1 <= H - 1) {
          n.next.push_back((i + 1) * W + j);
        }
        if (S[i - 1][j] == '.' && i - 1 >= 0) {
          n.next.push_back((i - 1) * W + j);
        }
        if (S[i][j + 1] == '.' && j + 1 <= W - 1) {
          n.next.push_back(i * W + j + 1);
        }
        if (S[i][j - 1] == '.' && j - 1 >= 0) {
          n.next.push_back(i * W + j - 1);
        }
        for (int k = 0; k < int(n.next.size()); k++) {
          printf("%d %d\n", i * W + j, n.next[k]);
        }
      }
      node[i * W + j] = n;
    }
  }
  int max_path = 0;
  for (size_t i = 0; i < node.size(); i++) {
    if (node[i].type == 0) {
      int path = get_path(node, i);
      if (path > max_path) max_path = path;
    }
  }
  printf("%d\n", max_path);
  return 0;
}
