#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
const long double pi = acos(-1);
const long long int mod = 1e9 + 7;
bool debug = false;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t = 1, n, i, j, k, len, x, y, z, c, f, flag, p, q, mx, mn, l, r,
                sum, ans, tmp, it, pos, avg, m, cnt;
  string s;
  char ch;
  vector<long long int> v;
  vector<pair<long long int, long long int>> vec;
  unordered_map<long long int, long long int> mappu;
  pair<long long int, long long int> pr;
  {
    f = 0;
    sum = 0;
    flag = 0;
    ans = 0;
    cnt = 0;
    v.clear();
    mappu.clear();
    vec.clear();
    cin >> n >> m;
    long long int a[1 + n][m + 1];
    memset(a, -1, sizeof(a));
    for (i = 1; i <= n; i++)
      for (j = 1; j <= m; j++) {
        cin >> ch;
        ch -= '0';
        a[i][j] = ch;
      }
    long long int x1, x2, y1, y2;
    for (x1 = 1; x1 <= n; x1++) {
      for (y1 = 1; y1 <= m; y1++) {
        for (x2 = x1; x2 <= n; x2++) {
          for (y2 = y1; y2 <= m; y2++) {
            flag = 0;
            for (i = x1; i <= x2; i++)
              for (j = y1; j <= y2; j++)
                if (a[i][j]) {
                  flag = 1;
                  break;
                }
            if (flag) continue;
            x = x2 - x1 + 1;
            y = y2 - y1 + 1;
            x *= 2;
            y *= 2;
            ans = max(ans, x + y);
          }
        }
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
