#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<string> room;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    room.push_back(s);
  }
  bool flag = true;
  int best = 0;
  for (int x1 = 0; x1 < n; x1++) {
    for (int y1 = 0; y1 < m; y1++) {
      for (int x2 = x1; x2 < n; x2++) {
        for (int y2 = y1; y2 < m; y2++) {
          flag = true;
          for (int cx = x1; cx <= x2; cx++) {
            for (int cy = y1; cy <= y2; cy++) {
              if (room[cx][cy] == '1') {
                flag = false;
                break;
              }
            }
            if (!flag) break;
          }
          if (flag) {
            best = max(best, 2 * (x2 - x1 + 1 + y2 - y1 + 1));
          }
        }
      }
    }
  }
  cout << best;
}
