#include using namespace std; int main(int argc, char* argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); uint64_t tt = 1; /* cin >> tt; */ while(tt--) { uint64_t n, m; cin >> n >> m; uint64_t res = 0; vector> v; for(uint64_t i = 0; i < n; i++) { vector vv; for(uint64_t ii = 0; ii < m; ii++) { uint64_t x; cin >> x; res += x; vv.push_back(x); } v.push_back(vv); } if(n % 2 == 0 && m % 2 == 0) { res -= min(v[n - 1][m - 2], v[n - 2][m - 1]); } cout << res << "\n"; } return 0; }