#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
const long long int SIZE = 1e6 + 10;
priority_queue<long long int, vector<long long int>, greater<long long int> > Q;
vector<long long int> arr[SIZE];
vector<long long int> seq;
bool res[SIZE];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, m;
  cin >> n >> m;
  char ch;
  long long int arr[n][m];
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      cin >> ch;
      arr[i][j] = ch - '0';
    }
  }
  long long int ans = 0;
  for (long long int x1 = 0; x1 < n; x1++) {
    for (long long int y1 = 0; y1 < m; y1++) {
      long long int Y = m - 1;
      if (arr[x1][y1] == 1) {
        continue;
      }
      for (long long int x2 = x1; x2 < n; x2++) {
        for (long long int y2 = y1; y2 <= Y; y2++) {
          if (arr[x2][y2] == 1) {
            Y = y2 - 1;
            break;
          }
        }
        if (Y >= y1) {
          ans = max(ans, 2 * ((x2 - x1) + (Y - y1) + 2));
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
