#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 233, mxzt = (1 << 20) + 23;
int f[21][mxzt], tmp[2][mxzt][20];
int stv[maxn];
int i, j, k, n, m;
char s[maxn];
int ra, fh;
char rx;
inline int read() {
  rx = getchar(), ra = 0, fh = 1;
  while (rx < 48) rx == '-' && (fh = -1), rx = getchar();
  while (rx > 47) ra = ra * 10 + rx - 48, rx = getchar();
  return ra * fh;
}
inline int getnum1(int x) {
  int n = 0;
  while (x) n += x & 1, x >>= 1;
  return n;
}
inline int min(int a, int b) { return a < b ? a : b; }
int main() {
  n = read(), m = read();
  int mx = 1 << n;
  for (i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (j = 1; j <= m; j++) stv[j] = stv[j] << 1 | (s[j] - 48);
  }
  for (i = 1; i <= m; i++) f[0][stv[i]]++;
  int zt, p, nf;
  bool now = 1, pre = 0;
  int *nt;
  for (i = 1; i <= n; i++, swap(now, pre)) {
    for (zt = 0; zt < mx; zt++) {
      for (nf = p = 0, nt = tmp[now][zt]; p < n; p++, nt++)
        nf += (*nt = f[i - 1][zt ^ (1 << p)] - tmp[pre][zt ^ (1 << p)][p]);
      f[i][zt] = nf / i;
    }
  }
  int ans = 1e9;
  for (zt = 0; zt < mx; zt++) {
    k = 0;
    for (j = 0; j <= n && k < ans; j++) k += min(j, n - j) * f[j][zt];
    if (j > n) ans = k;
  }
  printf("%d\n", ans);
}
