#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:16000000")
#pragma warning(disable : 4996)
const int inf = 1 << 25;
const double eps = 1e-9;
vector<string> a;
bool ok(int i1, int i2, int j1, int j2) {
  for (int i = (i1); i < (i2 + 1); ++i)
    for (int j = (j1); j < (j2 + 1); ++j)
      if (a[i][j] == '1') return false;
  return true;
}
int main() {
  int n, m;
  cin >> n >> m;
  a.resize(n);
  for (int i = (0); i < (n); ++i) cin >> a[i];
  int ans = 0;
  for (int i1 = (0); i1 < (n); ++i1)
    for (int i2 = (i1); i2 < (n); ++i2)
      for (int j1 = (0); j1 < (m); ++j1)
        for (int j2 = (j1); j2 < (m); ++j2)
          if (ok(i1, i2, j1, j2))
            ans = max(ans, 2 * (i2 - i1 + 1 + j2 - j1 + 1));
  cout << ans << endl;
  return 0;
}
