#include <bits/stdc++.h>
using namespace std;
int s[30][30];
int main() {
  int m, n, i, j, k, pm = 0;
  char c;
  cin >> n >> m;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      cin >> c;
      s[i][j + 1] = s[i][j];
      if (c != '0') s[i][j + 1]++;
    }
  int p = 0;
  for (i = 0; i < m; i++)
    for (j = i; j < m; j++) {
      for (k = 0; k < n; k++) {
        if (s[k][j + 1] == s[k][i]) {
          p += 2;
        } else if (p != 0) {
          pm = max(pm, p + 2 * (j - i + 1));
          p = 0;
        }
      }
      if (p > 0) {
        pm = max(pm, p + 2 * (j - i + 1));
        p = 0;
      }
    }
  cout << pm;
  return 0;
}
