#include <bits/stdc++.h>
using namespace std;
char s[100005];
int num[100005];
long long f[1 << 21], a[1 << 21];
void FWT_xor(long long *a, int n, int opt) {
  for (int l = 2; l <= n; l <<= 1) {
    int m = l >> 1;
    for (long long *p = a; p != a + n; p += l) {
      for (int i = 0; i < m; i++) {
        long long x = p[i], y = p[i + m];
        p[i] = x + y;
        p[i + m] = x - y;
        if (opt == -1) p[i] /= 2, p[i + m] /= 2;
      }
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    for (int j = 0; j < m; j++)
      if (s[j] == '1') num[j] += 1 << i;
  }
  for (int i = 0; i < m; i++) ++a[num[i]];
  for (int i = 0; i < (1 << n); i++) {
    int j = i, cnt = 0;
    while (j) {
      j &= j - 1;
      ++cnt;
    }
    f[i] = min(cnt, n - cnt);
  }
  FWT_xor(a, 1 << n, 1);
  FWT_xor(f, 1 << n, 1);
  for (int i = 0; i < (1 << n); i++) a[i] *= f[i];
  FWT_xor(a, 1 << n, -1);
  long long ans = 1 << 30;
  for (int i = 0; i < (1 << n); i++) ans = min(ans, a[i]);
  printf("%I64d\n", ans);
  return 0;
}
