#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
set<int> se;
set<int>::iterator it;
char arr[26][26];
int x, y, z, n, m, sol = 0;
int main() {
  bool f = 0;
  cin >> x >> y;
  for (int i = 0; i < x; i++)
    for (int j = 0; j < y; j++) cin >> arr[i][j];
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      for (int k = i; k < x; k++) {
        for (int t = j; t < y; t++) {
          f = 0;
          for (int a = i; a <= k; a++) {
            for (int b = j; b <= t; b++) {
              if (arr[a][b] == '1') {
                f = 1;
                break;
              }
            }
          }
          if (f == 0) {
            sol = max(sol, 2 * (k - i + 1) + 2 * (t - j + 1));
          }
        }
      }
    }
  }
  cout << sol << endl;
  return 0;
}
