#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
const long long inf = 2147383647;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
const long long maxint = 2147483647;
const long long minint = -2147483648;
using namespace std;
char grid[30][30];
int room[30][30];
int main() {
  int row, col;
  scanf("%d %d", &row, &col);
  int i;
  for (i = 1; i <= row; i++) {
    scanf("%s", &grid[i][1]);
  }
  int j;
  for (i = 1; i <= row; i++) {
    for (j = 1; j <= col; j++) {
      if (grid[i][j] == '1') room[i][j] = 1;
    }
  }
  for (i = 1; i <= row; i++) {
    for (j = 1; j <= col; j++) {
      room[i][j] += room[i - 1][j];
    }
  }
  int k1, k2;
  int mx = 0;
  for (i = 1; i <= row; i++) {
    for (j = i; j <= row; j++) {
      k1 = 0;
      int cur = 0;
      for (k2 = 1; k2 <= col; k2++) {
        cur += room[j][k2] - room[i - 1][k2];
        if (cur == 0) {
          int temp = 2 * (j - i + 1) + 2 * (k2 - k1);
          if (temp > mx) mx = temp;
        } else {
          k1 = k2;
          cur = 0;
        }
      }
    }
  }
  printf("%d\n", mx);
  return 0;
}
