#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main(){
    int r, c;
    cin >> r >> c;

    ll res = 0;
    ll fourSquaresSum = 0;
    int LAST_SQUARES[2][2];
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            ll a;
            cin >> a;
            res += a;
            if(i >= r - 2 && j >= c - 2){
                LAST_SQUARES[r - i - 1][c - j - 1] = a;
                fourSquaresSum += a;
            }
        }
    }
    if(r % 2 != 0 || c % 2 != 0){
        cout << res << endl;
        return 0;
    }
    res -= fourSquaresSum;
    // remove last 4 squares.
    ll max =  LAST_SQUARES[0][0] + LAST_SQUARES[1][1] + std::max(LAST_SQUARES[1][0], LAST_SQUARES[0][1]);
    cout << (res + max) << endl;
}