#include <bits/stdc++.h>
using namespace std;
int n, m;
char a[35][35];
int h[35];
int l[35];
int r[35];
int output;
void Slove() {
  for (int i = 0; i < m; i++) {
    if (h[i] == 0) continue;
    for (int j = i; j >= 0; j--) {
      if (h[j] >= h[i])
        l[i] = j;
      else
        break;
    }
    for (int j = i; j < m; j++) {
      if (h[j] >= h[i])
        r[i] = j;
      else
        break;
    }
  }
  for (int i = 0; i < m; i++) {
    output = max(output, h[i] * 2 + (r[i] - l[i] + 1) * 2);
  }
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 0; i < n; i++) {
      scanf("%s", a[i]);
    }
    output = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        int cont = 0;
        int y = i;
        while (1) {
          if (a[y][j] == '0') {
            cont++;
            y++;
            if (y == n) break;
          } else
            break;
        }
        h[j] = cont;
      }
      Slove();
    }
    printf("%d\n", output);
  }
}
