#include <bits/stdc++.h>
using namespace std;
const int n = 1000000;
char m[50][50];
bool canput(int y, int x, int r, int c) {
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      if (m[y + i][x + j] == '1') return false;
    }
  }
  return true;
}
int solve(int r, int c) {
  int ret = 0;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      for (int height = 1; i + height <= r; height++) {
        for (int width = 1; j + width <= c; width++) {
          if (canput(i, j, height, width))
            ret = max(ret, 2 * height + 2 * width);
        }
      }
    }
  }
  return ret;
}
int main() {
  int r, c;
  for (int i = 0; i < 50; i++)
    for (int j = 0; j < 50; j++) m[i][j] = '0';
  while (cin >> r >> c) {
    for (int i = 0; i < r; i++) {
      cin >> m[i];
    }
    cout << solve(r, c) << endl;
  }
}
