#include <bits/stdc++.h>
using namespace std;
const int maxs = (1 << 20) + 2333, MOD = 998244353;
int c[maxs], g[maxs], n, m, full, pop[maxs];
char s[22][101010];
inline int mo(int x) {
  if (x >= MOD) return x - MOD;
  if (x < 0) return x + MOD;
  return x;
}
inline int muln(int x, int y) { return (long long)x * y % MOD; }
inline int qpow(int x, int y) {
  int ret = 1;
  for (; y; y >>= 1, x = muln(x, x))
    if (y & 1) ret = muln(ret, x);
  return ret;
}
int Base, Len;
int* fwt(int* A, int dwt = 1) {
  int l, r;
  for (int i = 0; i < Base; ++i)
    for (int S = 0; S < Len; ++S)
      if (~S >> i & 1) {
        l = A[S], r = A[S | (1 << i)];
        A[S] = mo(l + r);
        A[S | (1 << i)] = mo(l - r);
      }
  if (dwt == -1) {
    int inv2 = qpow(Len, MOD - 2);
    for (int S = 0; S < Len; ++S) A[S] = muln(A[S], inv2);
  }
  return A;
}
int main() {
  scanf("%d%d", &n, &m);
  full = (1 << n) - 1;
  for (int i = 0; i < n; ++i) scanf("%s", s[i]);
  for (int i = 0; i < m; ++i) {
    int res = 0;
    for (int j = 0; j < n; ++j) res = 2 * res + s[j][i] - '0';
    c[res]++;
  }
  for (int S = 1; S <= full; ++S) {
    pop[S] = pop[S >> 1] + (S & 1);
    g[S] = min(pop[S], n - pop[S]);
  }
  Len = 1 << n, Base = n;
  fwt(c, 1);
  fwt(g, 1);
  for (int S = 0; S <= full; ++S) c[S] = muln(c[S], g[S]);
  fwt(c, -1);
  int ans = 0x3f3f3f3f;
  for (int S = 0; S <= full; ++S) ans = min(ans, c[S]);
  printf("%d\n", ans);
  return 0;
}
