#include <bits/stdc++.h>
using namespace std;
const int N=12;
int a[12][12]= {0};
int main() {
int n,m;
cin>>n>>m;
for(int i=1; i<=n; i++) {
for(int j=1; j<=n; j++) {
cin>>a[i][j];
a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
}
}
int ans=0;
for(int x1=1; x1<=n; x1++) {
for(int y1=1; y1<=m; y1++) {
for(int x2=x1; x2<=n; x2++) {
for(int y2=y1; y2<=m; y2++) {
if((y2-y1+1)*(x2-x1+1)%2==1) continue;
int now=a[x2][y2]-a[x1-1][y2]-a[x2][y1-1]+a[x1-1][y1-1];
if((y2-y1+1)*(x2-x1+1)/2==now) {
ans=max(ans,2*now);
}
}
}
}
}
cout<<ans;
return 0;
}