#include <bits/stdc++.h>
using namespace std;
char mp[30][30];
int high[30];
int le[30], ri[30];
int Q[30];
int n, m;
int work() {
  int rear = 0;
  for (int i = 0; i < m; i++) {
    while (rear && high[i] <= high[Q[rear - 1]]) rear--;
    if (rear)
      le[i] = Q[rear - 1] + 1;
    else
      le[i] = 0;
    Q[rear++] = i;
  }
  rear = 0;
  for (int i = m - 1; i >= 0; i--) {
    while (rear && high[i] <= high[Q[rear - 1]]) rear--;
    if (rear)
      ri[i] = Q[rear - 1] - 1;
    else
      ri[i] = m - 1;
    Q[rear++] = i;
  }
  int res = 0;
  for (int i = 0; i < m; i++) {
    res = max(res, high[i] ? 2 * (ri[i] - le[i] + 1 + high[i]) : 0);
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", mp[i]);
  memset(high, 0, sizeof(high));
  int res = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < m; j++) {
      if (mp[i][j] == '0')
        high[j] = high[j] + 1;
      else
        high[j] = 0;
    }
    res = max(res, work());
  }
  cout << res << '\n';
  return 0;
}
