#include <bits/stdc++.h>
using namespace std;
string arr[26];
long long check(string *arr, long long n, long long a, long long b,
                long long len) {
  long long wid = 1, i, j, f;
  f = 1;
  for (i = a - 1; i >= 0; i--) {
    for (j = b; j < b + len; j++) {
      if (arr[i][j] == '1') {
        f = 0;
        break;
      }
    }
    if (f) {
      wid++;
    } else
      break;
  }
  f = 1;
  for (i = a + 1; i < n; i++) {
    for (j = b; j < b + len; j++) {
      if (arr[i][j] == '1') {
        f = 0;
        break;
      }
    }
    if (f) {
      wid++;
    } else
      break;
  }
  return 2 * (wid + len);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, m, i, ans = 0, a, b, len, j;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (i = 0; i < n; i++) {
    a = b = -1;
    for (j = 0; j < m; j++) {
      if (arr[i][j] == '0') {
        if (a == -1 and b == -1) {
          a = i;
          b = j;
          len = 1;
        } else
          len++;
      } else {
        if (a != -1 and b != -1) ans = max(ans, check(arr, n, a, b, len));
        a = b = -1;
      }
    }
    if (a != -1 and b != -1) ans = max(ans, check(arr, n, a, b, len));
  }
  cout << ans << '\n';
  return 0;
}
