#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, t = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') t = -1;
    c = getchar();
  }
  while (isdigit(c)) s = s * 10 + c - 48, c = getchar();
  return s * t;
}
const int maxn = 1048576, inf = 2e9 + 7;
inline void Min(long long &x, long long v) {
  if (x > v) x = v;
}
int n, m, N;
long long f[maxn], g[maxn];
char c[25][maxn];
inline void fwt(int l, int r, long long *f) {
  if (l == r) return;
  int mid = (l + r) >> 1, bit = (r - l + 1) >> 1;
  long long x, y;
  for (register int i = l; i <= mid; i++)
    x = f[i], y = f[i + bit], f[i] = x + y, f[i + bit] = x - y;
  fwt(l, mid, f), fwt(mid + 1, r, f);
}
inline void nfwt(int l, int r, long long *f) {
  if (l == r) return;
  int mid = (l + r) >> 1, bit = (r - l + 1) >> 1;
  long long x, y;
  nfwt(l, mid, f), nfwt(mid + 1, r, f);
  for (register int i = l; i <= mid; i++)
    x = f[i], y = f[i + bit], f[i] = (x + y) >> 1, f[i + bit] = (x - y) >> 1;
}
int main() {
  n = read(), m = read();
  for (register int i = 1; i <= n; i++) scanf("%s", c[i] + 1);
  int x;
  N = 1 << n;
  for (register int i = 1; i <= m; i++) {
    x = 0;
    for (register int j = 1; j <= n; j++) x = (x << 1) | (c[j][i] == '1');
    f[x]++;
  }
  for (register int i = 0; i <= N - 1; i++) g[i] = g[i >> 1] + (i & 1);
  for (register int i = 0; i <= N - 1; i++) g[i] = min(g[i], n - g[i]);
  fwt(0, N - 1, f), fwt(0, N - 1, g);
  for (register int i = 0; i <= N - 1; i++) f[i] = f[i] * g[i];
  nfwt(0, N - 1, f);
  long long ans = inf;
  for (register int i = 0; i <= N - 1; i++) Min(ans, f[i]);
  cout << ans << endl;
  return 0;
}
