#include <bits/stdc++.h>
using namespace std;
inline bool is_digit(char c) { return c <= '9' && c >= '0'; }
inline int read() {
  int tmp = 0, f = 1;
  char c = getchar();
  while (!is_digit(c)) {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (is_digit(c)) tmp = (tmp << 1) + (tmp << 3) + (c ^ 48), c = getchar();
  return tmp * f;
}
void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar((x % 10) ^ 48);
}
const int maxn = 2000010;
const int mod = 998244353;
const int inv2 = 499122177;
int n, a[maxn], b[maxn], f[maxn], g[maxn];
inline void fwt_or() {
  for (int k = 2, len = 1; k <= n; k <<= 1, len <<= 1) {
    for (int i = 0; i < n; i += k) {
      for (int j = 0; j < len; j++) {
        f[i + j + len] += f[i + j], g[i + j + len] += g[i + j];
        f[i + j + len] %= mod, g[i + j + len] %= mod;
      }
    }
  }
}
inline void fwt_and() {
  for (int k = 2, len = 1; k <= n; k <<= 1, len <<= 1) {
    for (int i = 0; i < n; i += k) {
      for (int j = 0; j < len; j++) {
        f[i + j] += f[i + j + len], g[i + j] += g[i + j + len];
        f[i + j] %= mod, g[i + j] %= mod;
      }
    }
  }
}
inline void fwt_xor() {
  for (int k = 2, len = 1; k <= n; k <<= 1, len <<= 1) {
    for (int i = 0; i < n; i += k) {
      for (int j = 0; j < len; j++) {
        int ra = f[i + j], rb = f[i + j + len];
        f[i + j] += rb;
        f[i + j] %= mod;
        f[i + j + len] = ra - rb;
        f[i + j + len] %= mod;
        f[i + j + len] += mod;
        f[i + j + len] %= mod;
        ra = g[i + j], rb = g[i + j + len];
        g[i + j] += rb;
        g[i + j] %= mod;
        g[i + j + len] = ra - rb;
        g[i + j + len] %= mod;
        g[i + j + len] += mod;
        g[i + j + len] %= mod;
      }
    }
  }
}
inline void ifwt_or() {
  for (int k = 2, len = 1; k <= n; k <<= 1, len <<= 1) {
    for (int i = 0; i < n; i += k) {
      for (int j = 0; j < len; j++) {
        f[i + j + len] -= f[i + j];
        f[i + j + len] %= mod;
        f[i + j + len] += mod;
        f[i + j + len] %= mod;
      }
    }
  }
}
inline void ifwt_and() {
  for (int k = 2, len = 1; k <= n; k <<= 1, len <<= 1) {
    for (int i = 0; i < n; i += k) {
      for (int j = 0; j < len; j++) {
        f[i + j] -= f[i + j + len];
        f[i + j] %= mod;
        f[i + j] += mod;
        f[i + j] %= mod;
      }
    }
  }
}
inline void ifwt_xor() {
  for (int k = 2, len = 1; k <= n; k <<= 1, len <<= 1) {
    for (int i = 0; i < n; i += k) {
      for (int j = 0; j < len; j++) {
        int ra = f[i + j], rb = f[i + j + len];
        f[i + j] += rb;
        f[i + j] %= mod;
        f[i + j + len] = ra - rb;
        f[i + j + len] %= mod;
        f[i + j + len] += mod;
        f[i + j + len] %= mod;
        f[i + j] = 1ll * f[i + j] * inv2 % mod;
        f[i + j + len] = 1ll * f[i + j + len] * inv2 % mod;
      }
    }
  }
}
int mp[30][100010], c[100010];
int main() {
  n = read();
  int m = read();
  for (register int i = 1; i <= n; i++) {
    for (register int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      if (c == '1') mp[i][j] = 1;
    }
  }
  for (register int j = 1; j <= m; j++) {
    for (register int i = 1; i <= n; i++) {
      if (mp[i][j]) c[j] |= 1 << i - 1;
    }
  }
  for (register int i = 1; i <= m; i++) a[c[i]]++;
  for (register int i = 0; i <= (1 << n); i++) b[i] = b[i >> 1] + (i & 1);
  for (register int i = 0; i <= (1 << n); i++) b[i] = min(b[i], n - b[i]);
  n = 1 << n;
  for (register int i = 0; i < n; i++) f[i] = a[i];
  for (register int i = 0; i < n; i++) g[i] = b[i];
  fwt_xor();
  for (register int i = 0; i < n; i++) f[i] = 1ll * f[i] * g[i] % mod;
  ifwt_xor();
  int ans = f[0];
  for (register int i = 1; i < n; i++) {
    ans = min(ans, f[i]);
  }
  cout << ans << endl;
  return 0;
}
