#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t, n, m, a, b, c, q, k, d, x;     cin >> n >> m;     vector<vector<int>> mat(n + 1, vector<int>(m + 1)),         ans(n + 1, vector<int>(m + 1));     char ch;     for (int i = 1; i < n + 1; i++) {       for (int j = 1; j < m + 1; j++) {         cin >> ch;         mat[i][j] = ch -  0 ;         ans[i][j] = ans[i - 1][j] + ans[i][j - 1] - ans[i - 1][j - 1] + mat[i][j];       }     }     a = 0;     for (int i = 1; i < n + 1; i++) {       for (int j = 1; j < m + 1; j++) {         for (int i_ = i; i_ < n + 1; i_++) {           for (int j_ = j; j_ < m + 1; j_++) {             if (ans[i_][j_] - ans[i - 1][j_] - ans[i_][j - 1] +                     ans[i - 1][j - 1] ==                 0) {               a = max(a, 2 * (i_ - i + 1 + j_ - j + 1));             }           }         }       }     }     cout << a <<   n ;     return 0;   }   