#include <bits/stdc++.h>
int main(int agrc, char* argv[]) {
  int N, M;
  scanf("%d %d", &N, &M);
  char room[625];
  for (int i = 0; i < N * M; i++) scanf(" %c", room + i);
  int dp[625];
  for (int i = 0; i < M * M; i++) dp[i] = 0;
  int best = 0;
  for (int r = 0; r < N; r++) {
    for (int pl = 0; pl < M; pl++)
      for (int pr = pl; pr < M; pr++) {
        bool free = true;
        for (int i = pl; i <= pr && free; i++) free &= room[M * r + i] == '0';
        if (free) {
          if (dp[pl * M + pr] == 0) {
            dp[pl * M + pr] = 2 + 2 * (pr - pl + 1);
          } else {
            dp[pl * M + pr] += 2;
          }
        } else {
          dp[pl * M + pr] = 0;
        }
      }
    for (int i = 0; i < M * M; i++)
      if (dp[i] > best) best = dp[i];
  }
  printf("%d\n", best);
  return 0;
}
