#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long int N, M;
    cin >> N >> M;
    unsigned int mat[N][M];


    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> mat[i][j];
        }
    }

    if(N == 1){
    for(int i = 0; i < 64; i++){
        unsigned long long int d = pow(2,i);
        int ctr = 0;
        for(int j = 0; j < M; j++){
            if((mat[0][j] ^ d) < mat[0][j]){
                ctr++;
            }
            else{
                ctr--;
            }
        }
        if(ctr > 0){
            for(int j = 0; j < M; j++){
                mat[0][j] = mat[0][j] ^ d;
            }
        }
    }
    }
    else{
    for(int i = 0; i < 64; i++){
        unsigned long long int d = pow(2,i);

        unsigned long long int sumb = 0;
        int keyb = -1;
        while(true){


        for(int j = 0; j < M; j++){
            unsigned long long int sum = 0, sum1 = 0;
            for(int k = 0; k <= j; k++){
                sum += mat[0][k];
                sum1 += mat[0][k] ^ d;
            }
            for(int k = j; k < M; k++){
                sum += mat[1][k];
                sum1 += mat[1][k] ^ d;
            }
            if(sum1 < sumb){
                sumb = sum1;
                keyb = j;
            }
            else if(sum < sumb){
                sumb = sum;
                keyb = -1;
            }
        }
        if(keyb != -1){
            for(int j = 0; j <= keyb; j++){
                mat[0][j] = mat[0][j]^d;
            }
            for(int j = 0; j <= keyb; j++){
                mat[0][j] = mat[0][j]^d;
            }
            keyb = -1;
            cout << endl << endl << "uspesno za keyb = " << keyb << " sumb = " << sumb << "d = " << d << endl;
        }
        else{
            break;
        }
        }
    }
    }

    if(N == 1){
    unsigned long long int sum = 0;
        for(int j = 0; j < M; j++){
            sum += mat[0][j];
        }

    cout << sum;
    }
    else{
    unsigned long long int sum = 0;
        for(int j = 0; j < M; j++){
            sum += mat[0][j];
        }
        for(int j = 0; j < M; j++){
            sum += mat[1][j];
        }

    cout << sum;
    }


    return 0;
}