#include <bits/stdc++.h>
using namespace std;
bitset<25> mask[30];
int n, m;
string str[30];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> str[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 25; j++)
      if (j < m)
        mask[i][j] = (str[i][j] - '0') ^ 1;
      else
        mask[i][j] = 0;
  int res = 0;
  for (int i = 0; i < n; i++) {
    bitset<25> acc;
    acc.set();
    for (int j = i; j < n;) {
      acc &= mask[j++];
      for (int l = 0, r = 0; l < m; l = r) {
        while (l < m && acc[l] == 0) l++;
        if (l == m) break;
        r = l;
        while (r < m && acc[r] == 1) r++;
        res = max((j - i + r - l) * 2, res);
      }
    }
  }
  cout << res << endl;
  return 0;
}
