#include <bits/stdc++.h>
using namespace std;
const long long maxN = 3e1 + 7, MOD = 81409, inf = 1e9, N = 1e4 + 7;
long long n, m, ans;
bool a[maxN][maxN], good;
string d;
int main() {
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    cin >> d;
    for (long long j = 0; j < d.size(); j++)
      if (d[j] == '1') a[i][j + 1] = true;
  }
  for (long long i = 1; i <= m; i++) {
    for (long long j = i; j <= m; j++) {
      for (long long x = 1; x <= n; x++) {
        for (long long y = x; y <= n; y++) {
          good = true;
          for (long long o = x; o <= y; o++) {
            for (long long l = i; l <= j; l++)
              if (a[o][l]) good = false;
          }
          if (good) ans = max(ans, 2 * (j - i + y - x + 2));
        }
      }
    }
  }
  return cout << ans << "\n", 0;
}
