#include using namespace std; typedef long long int ll; typedef pair P; typedef vector VI; typedef vector VVI; const ll MOD = 1000000007; const ll INF = 1e18; #define REP(i, n) for(int i = 0; i < n; i++) #define ALL(v) v.begin(), v.end() int main(){ int n, m; cin >> n >> m; VI a(n,0); ll b; REP(i,n)REP(j,m){ cin >> b; a[i]+=b; } VVI dp(n+1,VI(2,-INF)); dp[0][0]=0; REP(i,n){ dp[i+1][1]=dp[i][1]; dp[i+1][0]=max(0ll,dp[i][0]); 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][1]-a[i]); } ll ans=max(dp[n][0],dp[n][1]); cout << ans << endl; return 0; }