#include using namespace std; typedef long long ll; typedef double ld; int main() { int n, m; cin >> n >> m; vector> p(n, vector(m)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> p[i][j]; } } ll ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { ans += p[i][j]; } } if ((n % 2 == 1) or (m % 2 == 1)) { cout << ans << endl; } else { int mini = 99999999; for (int i = 0; i < n; i++) { for (int j = (i % 2) + 1; j < m; j += 2) { if (mini > p[i][j]) mini = p[i][j]; } } cout << ans - mini << endl; } return 0; }