#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
string ss[22];
int ar[1 << 13][1 << 7][16], bitcount[1 << 16];
int val[100001][2];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int i = (0); i < (1 << 16); ++i) bitcount[i] = __builtin_popcount(i);
  int n, m;
  cin >> n >> m;
  for (int i = (0); i < (n); ++i) {
    cin >> ss[i];
  }
  int len1 = ((n + 2) / 3), len2 = n - len1;
  for (int i = (0); i < (m); ++i) {
    int v1 = 0;
    for (int j = (0); j < (len1); ++j) {
      if (ss[j][i] == '1') v1 ^= 1 << j;
    }
    int v2 = 0;
    for (int j = (len1); j < (n); ++j) {
      if (ss[j][i] == '1') v2 ^= 1 << (j - len1);
    }
    val[i][0] = v1;
    val[i][1] = v2;
  }
  for (int i = (0); i < (1 << len2); ++i) {
    for (int j = (0); j < (m); ++j) {
      ar[i][val[j][0]][bitcount[val[j][1] ^ i]]++;
    }
  }
  int res = INT_MAX / 3;
  for (int j = (0); j < (1 << len2); ++j) {
    for (int i = (0); i < (1 << len1); ++i) {
      int sum = 0;
      for (int k = (0); k < (1 << len1); ++k) {
        int v = bitcount[k ^ i];
        for (int l = (0); l < (len2 + 1); ++l) {
          sum += min(n - v - l, v + l) * ar[j][k][l];
        }
      }
      res = min(res, sum);
    }
  }
  cout << res << endl;
}
