#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    //radimo bit po bit
    int n, m;
    cin >> n >> m;

    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) {
        ll ans = 0;
        for(int j = 0; j <= 30; ++j) {
            int ima = 0;
            for(int i = 0; i < m; ++i) {
                if((mat[0][i] >> j) & 1) ++ima;
            }

            if(m - ima < ima) {
                ima = m - ima;
            }

            ans += (1LL << j) * ima;
        }

        cout << ans << '\n';
        return 0;
    }

    cout << 28 << '\n';
}