#include <bits/stdc++.h>
using namespace std;
int n, m, t, cnt[(1 << 20) + 10], c[100010];
long long ans[(1 << 20) + 10], f[(1 << 20) + 10], tot[(1 << 20) + 10],
    mn = 1e10;
void get01(int& x) {
  x = getchar();
  while (x != '0' && x != '1') x = getchar();
  x -= '0';
}
void FWT(long long* F, const int& len, const int& op) {
  long long t1, t2;
  for (int i = 2, tl = 1; i <= (1 << len); i <<= 1, tl <<= 1)
    for (int j = 0; j < (1 << len); j += i)
      for (int k = j; k < j + tl; ++k)
        t1 = F[k], t2 = F[k + tl], F[k] = (t1 + t2) / op,
        F[k + tl] = (t1 - t2) / op;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (1 << n); ++i)
    cnt[i] = cnt[i >> 1] + (i & 1), f[i] = min(cnt[i], n - cnt[i]);
  for (int i = 0; i < n; ++i)
    for (int j = 1; j <= m; ++j) get01(t), c[j] += t << i;
  for (int i = 1; i <= m; ++i) ++tot[c[i]];
  FWT(f, n, 1), FWT(tot, n, 1);
  for (int i = 0; i < (1 << n); ++i) ans[i] = f[i] * tot[i];
  FWT(ans, n, 2);
  for (int i = 0; i < (1 << n); ++i) mn = min(mn, ans[i]);
  printf("%I64d", mn);
  return 0;
}
