#include using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef vector vi; typedef vector> vvi; typedef vector> vpii; template using vec = vector; template using uset = unordered_set; template using umap = unordered_map; void solve () { ll N, M; cin >> N >> M; vvi larvea = vvi(N, vi(M)); ll sum = 0; rep(i, 0, N) { rep(i2, 0, M) { int count; cin >> count; larvea[i][i2] = count; sum += count; } } if (N % 2 || M % 2) { cout << sum << endl; } else { cout << sum - min(larvea[N-1][M-2], larvea[N-2][M-1]) << endl; } } int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); ll T = 1; //cin >> T; rep(i, 0, T) solve(); return 0; }