#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<string> x;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    x.push_back(s);
  }
  int ans = 0;
  for (int a = 0; a < n; a++) {
    for (int b = 0; b < m; b++) {
      for (int c = a; c < n; c++) {
        for (int d = b; d < m; d++) {
          bool bad = false;
          for (int i = a; i <= c; i++) {
            for (int j = b; j <= d; j++) {
              if (x[i][j] == '1') bad = true;
            }
          }
          if (!bad) {
            ans = max(ans, 2 * ((c - a + 1) + (d - b + 1)));
          }
        }
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
