#include <bits/stdc++.h>
using namespace std;
long long sum[26][26];
char a[26][26];
signed main() {
  long long n, m, ans = 0;
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      cin >> a[i][j];
      sum[i][j] =
          sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + (a[i][j] == '1');
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      for (long long x = i; x <= n; x++) {
        for (long long y = j; y <= m; y++) {
          long long cnt =
              sum[x][y] - sum[x][j - 1] - sum[i - 1][y] + sum[i - 1][j - 1];
          if (cnt == 0) {
            ans = max(ans, 2 * (x - i + y - j + 2));
          }
        }
      }
    }
  }
  cout << ans << endl;
}
