//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0352

#include<bits/stdc++.h>
const int N = 1005;
const int inf = 2e9;
using namespace std;

int n, m, a[N][N], dp[N][N];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> m >> n;
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> a[i][j];
    for (int i = n; i >= 0; i--) for (int j = m; j >= 0; j--) a[i][j] += a[i+1][j] + a[i][j+1] - a[i+1][j+1];
    dp[n][m] = 0;
    for (int i = n; i >= 0; i--) for (int j = m; j >= 0; j--){
        if (i == n && j == m) continue;
        if ((i + j) % 2 == 0) {
            dp[i][j] = -inf;
            if (i < n) dp[i][j] = max(dp[i][j], dp[i+1][j] + a[i+1][j+1] - a[i+2][j+1]);
            if (j < m) dp[i][j] = max(dp[i][j], dp[i][j+1] - a[i+1][j+1] + a[i+1][j+2]);
        }
        else {
            dp[i][j] = inf;
            if (i < n) dp[i][j] = min(dp[i][j], dp[i+1][j] + a[i+1][j+1] - a[i+2][j+1]);
            if (j < m) dp[i][j] = min(dp[i][j], dp[i][j+1] - a[i+1][j+1] + a[i+1][j+2]);
        }
    }
    cout << abs(dp[0][0]) << "\n";
}

