#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1504;
int a[MAXN][MAXN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

#ifdef OKRUZNOMAKS
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w",stdout);
#endif // OKRUZNOMAKS

    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    if(n == 1 && m == 1) {
        cout << 0 << endl;
    }
    else if(n==1 && m==2) {
        int ans = a[0][0] ^ (a[0][0] | a[0][1]) + a[0][1] ^ (a[0][0] | a[0][1]);
        cout <<ans<< endl;
    }
    else if(n==2 && m==1) {
        int ans =  a[0][0] ^ (a[0][0] | a[1][0]) + a[1][0] ^ (a[0][0] | a[1][0]);
        cout << ans << endl;
    }



    return 0;
}