#include using namespace std; using ll = long long; const ll mod = 1000000007; const int INF = 1001001001; ll dp[2][1001]; int main(){ int n, m; cin >> n >> m; vector happy(n); for(int i = 0; i < n; i++){ ll sum = 0; for(int j = 0; j < m; j++){ ll k; cin >> k; sum += k; } happy[i] = sum; } for(int j = 0; j < 2; j++){ for(int k = 0; k < 1001; k++){ dp[j][k] = -INF; } } dp[0][0] = 0; for(int i = 1; i <= n; i++){ for(int j = 0; j < 2; j++){ dp[j][i] = max(dp[j][i], dp[j][i - 1]); } for(int j = 0; j < 2; j++){ dp[j][i] = max(dp[j][i], dp[(j + 1) % 2][i - 1] + (j == 0 ? -1 : 1) * happy[i - 1]); } } cout << max(dp[0][n], dp[1][n]) << endl; }