#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  char c = getchar();
  int sgn = 1;
  while (c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  x *= sgn;
}
template <typename T>
void out(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x >= 10) out(x / 10);
  putchar(x % 10 + '0');
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
char a[100][100];
int b[100][100];
int sum[100][100];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      b[i][j] = a[i][j] - '0';
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + b[i][j];
    }
  }
  int maxn = 0;
  for (int x1 = 1; x1 <= n; x1++) {
    for (int y1 = 1; y1 <= m; y1++)
      for (int x2 = x1; x2 <= n; x2++)
        for (int y2 = y1; y2 <= m; y2++) {
          int ans = sum[x2][y2] - sum[x2][y1 - 1] - sum[x1 - 1][y2] +
                    sum[x1 - 1][y1 - 1];
          if (ans == 0) {
            int _ = (x2 - x1 + 1 + y2 - y1 + 1) * 2;
            if (_ > maxn) {
              maxn = _;
            }
          }
        }
  }
  cout << maxn << endl;
  return 0;
}
