#include <bits/stdc++.h>
using namespace std;
const long long OO = 1e8;
const double EPS = (1e-7);
int main() {
  int n, m;
  cin >> n >> m;
  string str[n];
  for (int i = 0; i < n; ++i) {
    cin >> str[i];
  }
  int ans = 0;
  for (int x1 = 0; x1 < n; ++x1) {
    for (int y1 = 0; y1 < m; ++y1) {
      for (int x2 = x1; x2 < n; ++x2) {
        for (int y2 = y1; y2 < m; ++y2) {
          int f = 1;
          for (int i = x1; i <= x2 && f; ++i) {
            for (int j = y1; j <= y2 && f; ++j) {
              if (str[i][j] == '1') f = 0;
            }
          }
          if (f) {
            ans = max(ans, (x2 - x1 + 1) + (y2 - y1 + 1));
          }
        }
      }
    }
  }
  cout << ans * 2 << endl;
  return 0;
}
