#include <bits/stdc++.h>
double Xor[2][2] = {{1, 1}, {1, -1}}, IXor[2][2] = {{0.5, 0.5}, {0.5, -0.5}};
int n, m, a[100001];
long long f[1 << 20], g[1 << 20], cnt[1 << 20];
void fwt(long long *f, int n, double c[2][2]) {
  for (int len = 2; len <= n; len <<= 1)
    for (int i = 0; i < n; i += len)
      for (int j = i; j < i + (len >> 1); ++j) {
        long long t1 = f[j], t2 = f[j + (len >> 1)];
        f[j] = c[0][0] * t1 + c[0][1] * t2;
        f[j + (len >> 1)] = c[1][0] * t1 + c[1][1] * t2;
      }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      int x;
      scanf("%1d", &x);
      a[j] |= x << i - 1;
    }
  for (int i = 0; i < 1 << n; ++i) cnt[i] = cnt[i >> 1] + (i & 1);
  for (int i = 1; i <= m; ++i) ++f[a[i]];
  for (int i = 0; i < 1 << n; ++i)
    g[i] = std::min(cnt[(1 << n) - 1 - i], cnt[i]);
  fwt(f, 1 << n, Xor);
  fwt(g, 1 << n, Xor);
  for (int i = 0; i < 1 << n; ++i) f[i] = 1ll * f[i] * g[i];
  fwt(f, 1 << n, IXor);
  long long ans = 1e18;
  for (int i = 0; i < 1 << n; ++i) ans = std::min(ans, f[i]);
  printf("%d\n", ans);
  return 0;
}
