#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a[110][110], sum[110];
  char c;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> c;
      if (c == '1')
        a[i][j] = -10000;
      else
        a[i][j] = 1;
    }
  }
  int maxPerimetro = 0;
  for (int i = 0; i < m; i++) {
    memset(sum, 0, sizeof(sum));
    for (int j = i; j < m; j++) {
      for (int k = 0; k < n; k++) {
        sum[k] += a[k][j];
      }
      int area = 0, left = 0, right = 0;
      for (int k = 0; k < n; k++) {
        if (area + sum[k] > sum[k]) {
          area += sum[k];
          right++;
        } else {
          area = sum[k];
          left = right = k;
        }
        if (area > 0) {
          maxPerimetro =
              max(maxPerimetro, 2 * (j - i + 1) + 2 * (right - left + 1));
        }
      }
    }
  }
  cout << maxPerimetro << "\n";
  return 0;
}
