#include <bits/stdc++.h>
char popcount[1 << 20], str[21][100010];
int n, m, r, p, lim, ar[100010], counter[14][1 << 7];
int main() {
  int i, j, k, l, c, d, x, y, z, lol, res, mask;
  for (i = 0; i < (1 << 20); i++) popcount[i] = __builtin_popcount(i);
  while (scanf("%d %d", &n, &m) != EOF) {
    for (i = 0; i < n; i++) scanf("%s", str[i]);
    memset(ar, 0, sizeof(ar));
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        if (str[i][j] == 49) ar[j] |= (1 << i);
      }
    }
    r = 13;
    if (n < r) r = n;
    lim = (1 << r) - 1, res = 1 << 25;
    for (mask = 0; mask <= lim; mask++) {
      memset(counter, 0, sizeof(counter));
      for (i = 0, z = 0; i < m; i++) {
        x = (ar[i] & lim) ^ mask;
        counter[popcount[x]][ar[i] >> r]++;
      }
      p = n - r, l = (1 << p) - 1;
      for (k = 0; k <= l; k++) {
        for (i = 0, z = 0; i <= r; i++) {
          for (j = 0; j <= l; j++) {
            if (counter[i][j]) {
              x = j ^ k, c = popcount[x] + i;
              if ((n - c) < c) c = n - c;
              z += (c * counter[i][j]);
            }
          }
        }
        if (z < res) res = z;
      }
    }
    printf("%d\n", res);
  }
  return 0;
}
