#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
const int mod = (int)1e9 + 7;
const int MAX = (int)1e2 + 5;
char a[MAX][MAX];
int dp[MAX][MAX];
int main(void) {
  int n, m;
  scanf("%d %d", &n, &m);
  ;
  for (int i = (1); i < (n + 1); ++i) scanf("%s", a[i] + 1);
  for (int i = (1); i < (n + 1); ++i)
    for (int j = (1); j < (m + 1); ++j) {
      dp[i][j] = m + 1;
      if (a[i][j] == '1') {
        for (int k = j - 1; k >= 1; --k) {
          if (a[i][k] == '1') break;
          dp[i][k] = j;
        }
      }
    }
  int ans = 0;
  for (int i = (1); i < (n + 1); ++i)
    for (int j = (1); j < (m + 1); ++j)
      if (a[i][j] == '0') {
        int r = 1, c = 25;
        for (int k = (i); k < (n + 1); ++k) {
          if (a[k][j] == '1') break;
          c = min(c, dp[k][j] - j);
          ans = max(ans, 2 * (r + c));
          r++;
        }
      }
  printf("%d\n", ans);
  return 0;
}
