#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) const long long INF = 1LL<<60; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; vector > a(n, vector(m)); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> a[i][j]; vector cur(2); cur[1] = -INF; for (int i = 0; i < n; i++) { vector nxt(2); long long sum = 0; for (int j = 0; j < m; j++) sum += a[i][j]; nxt[0] = max(cur[0], cur[1] - sum); nxt[1] = max(cur[1], cur[0] + sum); cur = nxt; } cout << max(cur[0], cur[1]) << endl; return 0; }