#include <bits/stdc++.h>
using namespace std;
char s[30][30];
int a, b;
int main() {
  while (~scanf("%d%d", &a, &b)) {
    for (int i = 0; i < a; i++) scanf("%s", s[i]);
    int ss = 0;
    for (int i = 0; i < a; i++) {
      for (int j = 0; j < b; j++) {
        int d = 99999999;
        if (s[i][j] == '0') {
          for (int k = 0; k <= i; k++) {
            if (s[i - k][j] == '1') break;
            int l;
            for (l = 1; l <= j; l++) {
              if (s[i - k][j - l] == '1') break;
            }
            d = min(d, l);
            ss = max(ss, d * 2 + (k + 1) * 2);
          }
        }
      }
    }
    printf("%d\n", ss);
  }
  return 0;
}
