#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<vector<int> > mm(n, vector<int>(m, 0));
  for (int i = 0; i < n; i++) {
    char c;
    scanf("%c", &c);
    for (int j = 0; j < m; j++) {
      scanf("%c", &c);
      mm[i][j] = c - '0';
    }
  }
  int mx = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int x = i; x < n; x++) {
        for (int y = j; y < m; y++) {
          bool ok = true;
          for (int ii = i; ii <= x; ii++) {
            for (int jj = j; jj <= y; jj++) {
              if (mm[ii][jj] == 1) ok = false;
            }
          }
          if (ok) mx = max(mx, x - i + y - j + 2);
        }
      }
    }
  }
  printf("%d", mx * 2);
  return 0;
}
