#include <bits/stdc++.h>
using namespace std;
int maxZ(int a[][25], int size, int row, int colum, int& stop);
int main() {
  int n, m, a[25][25];
  int size, maxSize = 0;
  cin >> n >> m;
  string tmp, tp;
  for (int i = 0; i < n; i++) {
    tmp = "";
    cin >> tmp;
    for (int K = 0; K < m; K++) {
      tp = "";
      tp += tmp[K];
      a[i][K] = atoi(tp.c_str());
    }
  }
  for (int i = 0; i < n; i++) {
    for (int K = 0; K < m; K++) {
      int stop = m;
      size = maxZ(a, n, i, K, stop);
      if (maxSize < size) {
        maxSize = size;
      }
    }
  }
  cout << maxSize << endl;
  return 0;
}
int maxZ(int a[][25], int size, int row, int colum, int& stop) {
  if (a[row][colum] != 0) return 0;
  int mainR = 0, maxCol = 0, minRCol = 0, col = 0;
  for (int i = row; i < size; i++) {
    col = 0;
    for (int K = colum; K < stop; K++) {
      if (a[i][K] != 0) {
        stop = K;
        break;
      }
      col++;
    }
    if ((i == row)) {
      minRCol = maxCol = col;
      mainR++;
    } else if (minRCol > col && a[i][0] == 0)
      minRCol = col;
    else if (maxCol == col)
      mainR++;
    if (stop == colum || i + 1 == size) {
      if (stop == colum) i--;
      int tableR = ((i + 1 - row) + minRCol);
      if ((mainR + maxCol) < tableR) {
        return tableR * 2;
      }
      return (mainR + maxCol) * 2;
    }
  }
}
