#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
long long int dx[] = {0, 1, 0, -1, -1, 1, -1, 1};
long long int dy[] = {-1, 0, 1, 0, -1, 1, 1, -1};
const long long int MAXN = 1e5 + 5;
const long long int N = 5e3 + 5;
long long int n, m;
long long int largestRectangleAreaInHisto(vector<long long int>& heights) {
  long long int n = heights.size();
  long long int mxParameter = 0;
  for (long long int i = 0; i < n; i++) {
    long long int h = heights[i];
    long long int left = 0, right = 0;
    for (long long int l = i - 1; l >= 0; l--) {
      if (heights[l] >= h) {
        left++;
      } else {
        break;
      }
    }
    for (long long int r = i + 1; r < n; r++) {
      if (heights[r] >= h) {
        right++;
      } else {
        break;
      }
    }
    long long int l = h, b = (left + right + 1);
    if (l > 0 && b > 0) mxParameter = max(mxParameter, 2 * (l + b));
  }
  return mxParameter;
}
void solve() {
  long long int x, y;
  cin >> n >> m;
  vector<string> a(n);
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<vector<long long int>> heights(n, vector<long long int>(m, 0));
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      if (i == 0) {
        heights[i][j] = 1 - (a[i][j] - '0');
      } else {
        if (a[i][j] == '1') {
          heights[i][j] = 0;
        } else {
          heights[i][j] += (1 + heights[i - 1][j]);
        }
      }
    }
  }
  long long int mxPArameter = 0;
  for (long long int i = 0; i < n; i++) {
    mxPArameter = max(mxPArameter, largestRectangleAreaInHisto(heights[i]));
  }
  cout << mxPArameter << "\n";
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) {
    solve();
  }
}
