#include <bits/stdc++.h>
using namespace std;
const long long M = 1e5 + 5;
long long n, m, G[25][M], S[M], lim, g[1 << 21], f[1 << 21], ans = 0x7f7f7f7f;
long long read() {
  long long x = 0, f = 1;
  char s;
  while ((s = getchar()) > '9' || s < '0')
    if (s == '-') f = -1;
  while (s >= '0' && s <= '9')
    x = (x << 1) + (x << 3) + (s ^ 48), s = getchar();
  return x * f;
}
void FWT(long long *f, const long long op = 1) {
  for (long long i = 2; i <= lim; i <<= 1)
    for (long long j = 0, p = i >> 1; j < lim; j += i)
      for (long long k = j; k < j + p; ++k) {
        long long x = f[k], y = f[k + p];
        f[k] = x + y;
        f[k + p] = x - y;
        if (op == -1) f[k] >>= 1, f[k + p] >>= 1;
      }
}
signed main() {
  n = read(), m = read();
  lim = 1 << n;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= m; ++j) G[i][j] = getchar() - '0';
    getchar();
  }
  for (long long i = 1; i <= m; ++i)
    for (long long j = 1; j <= n; ++j) S[i] |= G[j][i] * (1 << j - 1);
  for (long long i = 1; i <= m; ++i) ++f[S[i]];
  for (long long i = 0; i < lim; ++i) g[i] = g[i >> 1] + (i & 1);
  for (long long i = 0; i < lim; ++i) g[i] = min(g[i], n - g[i]);
  FWT(f), FWT(g);
  for (long long i = 0; i < lim; ++i) f[i] *= g[i];
  FWT(f, -1);
  for (long long i = 0; i < lim; ++i) ans = min(ans, f[i]);
  printf("%lld\n", ans);
  return 0;
}
