#include <bits/stdc++.h>
using namespace std;

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int n, m;
int a[1010][1010];
int b[1010] = {};

int memo[1010][2];
int dp(int i, int x){
	if(i == n) return 0;
	if(memo[i][x] != -1) return memo[i][x];
	return memo[i][x] = max(dp(i+1, x), dp(i+1, x == 1 ? 0 : 1) + (x == 0 ? 1 : -1) * b[i] );
}

signed main(){
	cin >> n >> m;

	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			cin >> a[i][j];
			b[i] += a[i][j];
		}
	}

	memset(memo, -1, sizeof(memo));
	cout << dp(0, 0) << endl;

	return 0;
}