#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  char a[27][27];
  int dp[27][27] = {{}};
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '0') {
        dp[i][j] = 4;
        int r = i;
        int mc = m;
        while (r < n && a[r][j] == '0') {
          int c = j;
          while (c < mc && a[r][c] == '0') {
            dp[i][j] = max(dp[i][j], 2 * (r - i + c - j + 2));
            c++;
          }
          mc = c;
          r++;
        }
      }
    }
  }
  int out = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      out = max(out, dp[i][j]);
    }
  }
  cout << out << "\n";
  return 0;
}
