#include <bits/stdc++.h>
using namespace std;
const int M = 110005;
long long read() {
  long long num = 0, flag = 1;
  char c;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flag = -1;
  while (c >= '0' && c <= '9')
    num = (num << 3) + (num << 1) + (c ^ 48), c = getchar();
  return num * flag;
}
long long n, m, lim, a[25][M], s[M], f[M * 10], g[M * 10];
void fwt(long long *a, long long n, long long op) {
  for (long long i = 1; i < n; i <<= 1)
    for (long long p = i << 1, j = 0; j < n; j += p)
      for (long long k = 0; k < i; k++) {
        long long x = a[j + k], y = a[i + j + k];
        a[j + k] = x + y;
        a[i + j + k] = x - y;
        if (op == -1) {
          a[j + k] = a[j + k] / 2;
          a[i + j + k] = a[i + j + k] / 2;
        }
      }
}
signed main() {
  n = read();
  m = read();
  lim = 1 << n;
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++) scanf("%1lld", &a[i][j]);
  for (long long i = 1; i <= m; i++)
    for (long long j = 1; j <= n; j++) s[i] |= (a[j][i] << j - 1);
  for (long long i = 1; i <= m; i++) f[s[i]]++;
  for (long long i = 0; i < lim; i++) g[i] = g[i >> 1] + (i & 1);
  for (long long i = 0; i < lim; i++) g[i] = min(g[i], n - g[i]);
  fwt(f, lim, 1);
  fwt(g, lim, 1);
  for (long long i = 0; i < lim; i++) f[i] = f[i] * g[i];
  fwt(f, lim, -1);
  long long ans = 1e9;
  for (long long i = 0; i < lim; i++) ans = min(ans, f[i]);
  printf("%lld\n", ans);
}
