#include using namespace std; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define P pair void chmax(ll& a, ll b) { if (a < b) a = b; } int main() { int n, m; cin >> n >> m; vector a(m), sum(n); rep(i, n) { rep(j, m) { cin >> a[j]; sum[i] += a[j]; } } ll dp[n+1][2] = {0}; rep(i, n) { chmax(dp[i+1][1], dp[i][1]); chmax(dp[i+1][0], dp[i][0]); chmax(dp[i+1][1], dp[i][0] + sum[i]); chmax(dp[i+1][0], dp[i][1] - sum[i]); } cout << max(dp[n][0], dp[n][1]) << endl; }