#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <string>
#include <cmath>
#include <limits>


int min = INT_MAX;
std::vector<std::vector<int>> mink;
void r(std::vector<std::vector<int>> k, int i, int j, int& p, int sum) {
    if (i >= k.size() || j >= k[0].size()) return;
    if (i == k.size() - 1 && j == k[0].size() - 1) {
        sum -= k[i][j];
        k[i][j] ^= p;
        sum += k[i][j];
        if (sum < min) {
            min = sum;
            
            mink = k;
        }
    }
    else {
        sum -= k[i][j];
        k[i][j] ^= p;
        sum += k[i][j];

        r(k, i + 1, j, p, sum);
        r(k, i, j + 1, p, sum);
    }
}

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

    int n, m;
    std::cin >> n >> m;
    std::vector<std::vector<int>> k(n, std::vector<int>(m, 0));
    int s = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            std::cin >> k[i][j];
            s += k[i][j];
        }
    }

    int res = s;
    bool b = true;

    while (b) {
        b = false;
        std::vector<std::vector<int>> mmk;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (k[i][j] != 0) {
                    min = INT_MAX;
                    r(k, 0, 0, k[i][j], s);
                    if (min < res) {
                        b = true;
                        res = min;
                        mmk = mink;
                    }
                }
            }
        }
        if (!b) break;
        k = mmk;
        s = res;

    }
    std::cout << res << std::endl;
}