#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000

int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<long long> A(N,0);
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			long long t;
			cin>>t;
			A[i]+=t;
		}
	}
	
	vector<vector<long long>> dp(N+1,vector<long long>(2,-Inf));
	dp[0][0] = 0;
	
	for(int i=0;i<N;i++){
		dp[i+1][0] = max(dp[i+1][0],dp[i][1] - A[i]);
		dp[i+1][1] = max(dp[i+1][1],dp[i][0] + A[i]);
		dp[i+1][0] = max(dp[i+1][0],dp[i][0]);
		dp[i+1][1] = max(dp[i+1][1],dp[i][1]);
	}
	
	cout<<max(dp.back()[0],dp.back()[1])<<endl;
	
	return 0;
}