#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
char maze[maxn][maxn];
int n, m;
void solve() {
  int res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (maze[i][j] == '0') {
        int uy = m - 1;
        for (int k = i; k < n; k++) {
          for (int p = j; p <= uy; p++) {
            if (maze[k][p] == '1') {
              uy = p - 1;
              break;
            } else
              res = max(res, 2 * (k - i + 1 + p - j + 1));
          }
        }
      }
    }
  }
  cout << res << endl;
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(maze, '1', sizeof(maze));
    for (int i = 0; i < n; i++) scanf("%s", maze[i]);
    solve();
  }
  return 0;
}
