#include <iostream>
#define forn(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
const int oo = 2e5+7;
int n, m;
ll a[oo*2];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    forn(i, n) forn(j, m) {
        ll kurac;
        cin >> kurac;
        a[i+j] ^= kurac;
    }
    ll k = n + m - 1;
    ll maxn = -1;
    forn(i, k) maxn = max(maxn, a[i]);
    ll lastxor = 0;
    ll p = 1;
    while (p <= maxn) {
        int ima1 = 0;
        forn(i, k) if (a[i] & p) ima1++;
        int ima0 = k - ima1;
        if (ima1 > ima0) lastxor += p;

        p *= 2;
    }
    ll sum = 0;
    forn(i, k) sum += a[i] ^ lastxor;
    cout << sum << endl;
}