#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> height(n, vector<int>(m + 1));
  {
    height[0][m] = 0;
    string row;
    cin >> row;
    transform(row.begin(), row.end(), height[0].begin(),
              [](char c) { return c == '0' ? 1 : 0; });
  }
  for (int i = 1; i < n; ++i) {
    height[i][m] = 0;
    string row;
    cin >> row;
    for (int j = 0; j < m; ++j) {
      height[i][j] = (row[j] == '0') ? height[i - 1][j] + 1 : 0;
    }
  }
  int perimeter = 0;
  for (int i = 0; i < n; ++i) {
    const vector<int>& h = height[i];
    stack<int> s;
    int j = 0;
    while (j <= m) {
      if (s.empty() || h[s.top()] <= h[j]) {
        s.push(j);
        ++j;
      } else {
        int t = s.top();
        s.pop();
        perimeter =
            max(perimeter, 2 * (h[t] + (s.empty() ? j : j - s.top() - 1)));
      }
    }
  }
  cout << perimeter;
  return 0;
}
