#include<bits/stdc++.h>
using namespace std;
#define el "\n"
#define ll long long
#define ull unsigned long long
#define se second
#define fi first
#define be begin()
#define en end()
#define Faster cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
int main()
{
Faster;
int n, m; cin >> n >> m;
int a[n][m];
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
cin >> a[i][j];
}
}
int ans = INT_MIN;
for(int i = 0; i < n - 1; i++)
{
for(int j = 0; j < m - 1; j++)
{
int tmp = 0;
for(int x = i; x < i + 2; x++)
{
for(int y = j; y < j + 2; y++)
{
tmp += a[x][y];
}
}
ans = max(ans, tmp);
}
}
cout << ans;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBlbCAiXG4iCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgdWxsIHVuc2lnbmVkIGxvbmcgbG9uZwojZGVmaW5lIHNlIHNlY29uZAojZGVmaW5lIGZpIGZpcnN0CiNkZWZpbmUgYmUgYmVnaW4oKQojZGVmaW5lIGVuIGVuZCgpCiNkZWZpbmUgRmFzdGVyIGNpbi50aWUoMCk7IGNvdXQudGllKDApOyBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwppbnQgbWFpbigpCnsKICAgIEZhc3RlcjsKICAgIGludCBuLCBtOyBjaW4gPj4gbiA+PiBtOwogICAgaW50IGFbbl1bbV07CiAgICBmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQogICAgewogICAgICAgIGZvcihpbnQgaiA9IDA7IGogPCBtOyBqKyspCiAgICAgICAgewogICAgICAgICAgICBjaW4gPj4gYVtpXVtqXTsKICAgICAgICB9CiAgICB9CiAgICBpbnQgYW5zID0gSU5UX01JTjsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuIC0gMTsgaSsrKQogICAgewogICAgICAgIGZvcihpbnQgaiA9IDA7IGogPCBtIC0gMTsgaisrKQogICAgICAgIHsKICAgICAgICAgICAgaW50IHRtcCA9IDA7CiAgICAgICAgICAgIGZvcihpbnQgeCA9IGk7IHggPCBpICsgMjsgeCsrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBmb3IoaW50IHkgPSBqOyB5IDwgaiArIDI7IHkrKykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICB0bXAgKz0gYVt4XVt5XTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBhbnMgPSBtYXgoYW5zLCB0bXApOwogICAgICAgIH0KICAgIH0KICAgIGNvdXQgPDwgYW5zOwp9Cg==