#include using namespace std; //#include //using namespace atcoder; typedef long long ll; typedef unsigned long long ull; const int MAX = 1e9; const int MIN = -1*1e9; const ll MAXLL = 1e18; const ll MINLL = -1*1e18; //const ll MOD = 998244353; //const ll MOD = 1000000007; int main() { ll N,M; cin >> N >> M; vector V(N); for(int i = 0; i < N; i++) { for(int j = 0; j < M; j++) { ll A; cin >> A; V[i] += A; } } vector> DP(N+1,vector(2,MINLL)); DP[0][0] = 0; for(int i = 0; i < N; i++) { DP[i+1][0] = max({DP[i+1][0],DP[i][0],DP[i][1]-V[i]}); DP[i+1][1] = max({DP[i+1][1],DP[i][1],DP[i][0]+(V[i])}); } cout << max(DP[N][0],DP[N][1]) << endl; return 0; }