#include using namespace std; int main(){ long long rows, cols; cin >> rows >> cols; long long sum = 0; long long min = -1; for(long long i = 0; i < rows; i++){ for(long long j = 0; j < cols; j++){ long long x; cin >> x; if(rows % 2 == 0 && cols % 2 == 0){ if(i%2 != j%2){ if(min == -1 || x < min) { min = x; } } } sum += x; } } if (min != -1) sum -= min; cout << sum << endl; }