#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
int cnt[65536];
int count(int x) { return cnt[x >> 16] + cnt[x & 65535]; }
void pre_count() {
  int i, j;
  for (i = 0; i < (1 << 16); i++)
    for (j = 0; j < 16; j++)
      if (i & (1 << j)) cnt[i]++;
}
void FWT_XOR(long long *s, int len, int type) {
  int i, j, k;
  long long tmp;
  for (k = 2; k <= len; k <<= 1)
    for (i = 0; i < len; i += k)
      for (j = 0; j < (k >> 1); j++) {
        tmp = s[i + j];
        s[i + j] = s[i + j] + s[i + j + (k >> 1)];
        s[i + j + (k >> 1)] = tmp - s[i + j + (k >> 1)];
        if (type == -1) s[i + j] >>= 1, s[i + j + (k >> 1)] >>= 1;
      }
}
int n, m;
long long a[(1 << 20) + 10], b[(1 << 20) + 10];
int c[(1 << 20) + 10];
char str[(1 << 20) + 10];
int main() {
  scanf("%d%d", &n, &m);
  int i, j;
  long long ans = inf;
  for (i = 0; i < n; i++) {
    scanf("%s", str + 1);
    for (j = 1; j <= m; j++) c[j] |= (str[j] - '0') << i;
  }
  pre_count();
  for (j = 1; j <= m; j++) a[c[j]]++;
  for (i = 0; i < (1 << n); i++) b[i] = min(count(i), n - count(i));
  FWT_XOR(a, (1 << n), 1);
  FWT_XOR(b, (1 << n), 1);
  for (i = 0; i < (1 << n); i++) a[i] = a[i] * b[i];
  FWT_XOR(a, (1 << n), -1);
  for (i = 0; i < (1 << n); i++) ans = min(ans, a[i]);
  printf("%lld\n", ans);
  return 0;
}
