#include <bits/stdc++.h>
using namespace std;
int n, m, grid[30][30], sum[30][30];
char c;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> c;
      grid[i][j] = c - '0';
    }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (grid[i][j] == 1) sum[i][j] = 1;
      sum[i][j] += (sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1]);
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = i; k <= n; k++) {
        for (int l = j; l <= m; l++) {
          int s = sum[k][l] - sum[i - 1][l] - sum[k][j - 1] + sum[i - 1][j - 1];
          if (s == 0) {
            int peri = 2 * (k - i + 1) + 2 * (l - j + 1);
            ans = max(ans, peri);
          }
        }
      }
    }
  }
  cout << ans << "\n";
}
