#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y, step;
} a, b;
int maxx = 0;
int n, m;
int mov[4][2] = {0, 1, 1, 0, -1, 0, 0, -1};
char mp[25][25];
int vis[25][25];
queue<node> q;
void bfs(int x, int y) {
  memset(vis, 0, sizeof(vis));
  a.x = x;
  a.y = y;
  vis[x][y] = 1;
  a.step = 0;
  q.push(a);
  while (!q.empty()) {
    a = q.front();
    printf("%d %d %d\n", a.x, a.y, a.step);
    if (a.step > maxx) maxx = a.step;
    q.pop();
    for (int i = 0; i < 4; i++) {
      int xx = a.x + mov[i][0];
      int yy = a.y + mov[i][1];
      if (xx < 1 || xx > n || yy < 1 || yy > m || vis[xx][yy] ||
          mp[xx][yy] == '#')
        continue;
      vis[xx][yy] = 1;
      b.x = xx;
      b.y = yy;
      b.step = a.step + 1;
      q.push(b);
    }
  }
}
int main() {
  int ans;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> mp[i] + 1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      if (mp[i][j] == '.') {
        bfs(i, j);
      }
    }
  cout << maxx << endl;
  return 0;
}
