#include <bits/stdc++.h>
using namespace std;
long long po(long long n, long long exp) {
  long long prod = 1;
  for (long long i = 0; i < exp; i++) prod = (prod * n);
  return prod;
}
signed main() {
  ios_base::sync_with_stdio(false);
  long long TESTS = 1;
  while (TESTS--) {
    long long n, m;
    cin >> n >> m;
    char a[n][m + 5];
    long long ans = 0;
    for (long long i = 0; i < n; i++) cin >> a[i];
    for (long long c = 1; c < 26; c++) {
      for (long long b = 1; b < 26; b++) {
        for (long long i = 0; i < n + 1 - c; i++) {
          for (long long j = 0; j < m + 1 - b; j++) {
            long long flag = 1;
            for (long long k = i; k < i + c; k++) {
              for (long long l = j; l < j + b; l++) {
                if (a[k][l] != '0') {
                  flag = 0;
                  goto nex;
                }
              }
            }
          nex:
            if (flag) ans = max(ans, 2 * (c + b));
          }
        }
      }
    }
    cout << ans;
  }
}
