#include <bits/stdc++.h>
using namespace std;
const int N = 20, M = (1 << 20) + 1;
int n, m, s[M], cnt[M];
long long f[M], g[M], Ans = 2e7;
char str[M];
void fwt_xor(long long *p, int o) {
  long long x, y;
  for (int i = 1; i < 1 << n; i <<= 1)
    for (int j = 0; j < 1 << n; j += (i << 1))
      for (int k = 0; k < i; ++k) {
        x = p[j + k], y = p[i + j + k];
        p[j + k] = x + y, p[i + j + k] = x - y;
        if (o == -1) p[j + k] >>= 1, p[i + j + k] >>= 1;
      }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", str + 1);
    for (int j = 1; j <= m; ++j) s[j] |= ((str[j] - '0') << i - 1);
  }
  for (int i = 1; i <= m; ++i) ++g[s[i]];
  for (int i = 1; i < 1 << n; ++i)
    cnt[i] = cnt[i - (i & (-i))] + 1, f[i] = min(cnt[i], n - cnt[i]);
  fwt_xor(g, 1), fwt_xor(f, 1);
  for (int i = 0; i < 1 << n; ++i) f[i] = f[i] * g[i];
  fwt_xor(f, -1);
  for (int i = 0; i < 1 << n; ++i) Ans = min(Ans, f[i]);
  printf("%lld", Ans);
  return 0;
}
