#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int inf = (int)1e9;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<char> > f(n, vector<char>(m));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) cin >> f[i][j];
  int res = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      for (int w = 1; j + w <= m; ++w)
        for (int h = 1; i + h <= n; ++h) {
          bool exist = true;
          for (int k = i; k < i + h; ++k)
            for (int l = j; l < j + w; ++l)
              if (f[k][l] != '0') {
                exist = false;
                break;
              }
          if (exist) res = max(res, 2 * h + 2 * w);
        }
  cout << res;
  return 0;
}
