#include <bits/stdc++.h>
const double PI = acos(-1.0);
using namespace std;
char p[26][26];
int cnt[26][26];
int main() {
  int n, m;
  scanf("%d %d\n", &n, &m);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      p[i][j] = getchar();
      cnt[i][j] = p[i][j] - '0';
    }
    getchar();
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 2; j <= m; ++j) cnt[i][j] += cnt[i][j - 1];
  }
  for (int i = 2; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) cnt[i][j] += cnt[i - 1][j];
  }
  int ans = 0;
  for (int l = 1; l <= n; ++l) {
    for (int r = 1; r <= m; ++r) {
      for (int ll = l; ll <= n; ++ll) {
        for (int rr = r; rr <= m; ++rr) {
          int sum =
              cnt[ll][rr] + cnt[l - 1][r - 1] - cnt[l - 1][rr] - cnt[ll][r - 1];
          if (!sum) {
            ans = max(ans, 2 * (ll - l + rr - r + 2));
          }
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
