#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c;
  do c = getchar(), f = c == '-' ? -1 : f;
  while (!isdigit(c));
  do x = (x << 3) + (x << 1) + c - '0', c = getchar();
  while (isdigit(c));
  return x * f;
}
int n, m, p;
long long tmp;
long long f[2000050], a[2000050], b[2000050], ans[2000050], g[2000050];
inline void fwt(long long *a, int mode) {
  for (int i = 2; i <= p + 1; i <<= 1) {
    int mid = i >> 1;
    for (int j = 0; j <= p + 1; j += i) {
      for (int k = j; k < j + mid; k++) {
        long long x = a[k], y = a[k + mid];
        if (mode == 1)
          a[k] = x + y, a[k + mid] = x - y;
        else
          a[k] = (x + y) / 2, a[k + mid] = (x - y) / 2;
      }
    }
  }
}
char s[2000050];
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (int j = 1; j <= m; j++) a[j] = (a[j] << 1) + (s[j] == '1');
  }
  p = (1 << n) - 1;
  for (int i = 1; i <= p; i++) f[i] = f[i >> 1] + (i & 1);
  for (int i = 1; i <= m; i++) b[a[i]]++;
  for (int i = 1; i <= p; i++) g[i] = min(f[i], n - f[i]);
  fwt(g, 1);
  fwt(b, 1);
  for (int i = 0; i <= p; i++) ans[i] = g[i] * b[i];
  fwt(ans, 0);
  tmp = 2147483647;
  for (int i = 0; i <= p; i++) tmp = min(tmp, ans[i]);
  printf("%lld", tmp);
  return 0;
}
