#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
char s[21][100005];
int F1[2000005], F2[2000005];
long long poww(long long a, long long b) {
  long long t = 1;
  while (b > 1) {
    if (b % 2 == 1) t = t * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return a * t % mod;
}
void FWT(int *F, int n, int opt) {
  const int inv2 = poww(2, mod - 2);
  for (int i = 1; i < n; i <<= 1) {
    for (int p = i << 1, j = 0; j < n; j += p) {
      for (int k = 0; k < i; k++) {
        int x = F[j + k], y = F[i + j + k];
        F[j + k] = (x + y) % mod;
        F[i + j + k] = ((x - y) % mod + mod) % mod;
        if (opt == -1)
          F[j + k] = 1LL * F[j + k] * inv2 % mod,
                F[i + j + k] = 1LL * F[i + j + k] * inv2 % mod;
      }
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (1 << n); i++) {
    int temp = i, cnt1 = 0;
    while (temp) {
      if (temp % 2 == 1) cnt1++;
      temp >>= 1;
    }
    F2[i] = min(cnt1, n - cnt1);
  }
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= m; i++) {
    int temp = 0;
    for (int j = 1; j <= n; j++) {
      temp *= 2;
      if (s[j][i] == '1') temp++;
    }
    F1[temp]++;
  }
  FWT(F1, 1 << n, 1);
  FWT(F2, 1 << n, 1);
  for (int i = 0; i < (1 << n); i++) {
    F1[i] = 1LL * F1[i] * F2[i] % mod;
  }
  FWT(F1, 1 << n, -1);
  int ans = 1e9;
  for (int i = 0; i < (1 << n); i++) ans = min(ans, F1[i]);
  printf("%d\n", ans);
  return 0;
}
