#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
char s[21][100100];
int n, m, ans = 1e9, all, inv, a[100100], bit[1100000], w[1100000], f[1100000];
int power(int a, int k) {
  int ret = 1;
  while (k) {
    if (k & 1) ret = 1ll * ret * a % mod;
    a = 1ll * a * a % mod;
    k >>= 1;
  }
  return ret;
}
void FWT(int *a, int t) {
  int pre, cur = 0;
  static int f[2][1100000];
  for (int i = 0; i <= all; i++) f[0][i] = a[i];
  for (int i = 0; i <= n - 1; i++) {
    pre = cur, cur ^= 1;
    for (int s = 0; s <= all; s++)
      if (!(s >> i & 1)) {
        int l = f[pre][s], r = f[pre][s | (1 << i)];
        f[cur][s] = (l + r) % mod;
        f[cur][s | (1 << i)] = (l + mod - r) % mod;
      }
  }
  if (t)
    for (int i = 0; i <= all; i++) f[cur][i] = 1ll * f[cur][i] * inv % mod;
  for (int i = 0; i <= all; i++) a[i] = f[cur][i];
}
int main() {
  scanf("%d%d", &n, &m);
  all = (1 << n) - 1;
  inv = power(power(2, mod - 2), n);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) a[i] = (a[i] << 1) + s[j][i] - '0';
  for (int i = 1; i <= all; i++) bit[i] = bit[i >> 1] + (i & 1);
  for (int i = 1; i <= m; i++) f[a[i]]++;
  for (int i = 0; i <= all; i++) w[i] = min(bit[i], n - bit[i]);
  FWT(f, 0);
  FWT(w, 0);
  for (int i = 0; i <= all; i++) f[i] = 1ll * f[i] * w[i] % mod;
  FWT(f, 1);
  for (int i = 0; i <= all; i++) ans = min(ans, f[i]);
  printf("%d\n", ans);
}
