#include <bits/stdc++.h>
using namespace std;
int n, m, ans;
int f[3][1100010], g[1100010];
char a[21][100010];
int main() {
  int i, j, k, i0, i1, i2, s;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%s", a[i] + 1);
  for (i = 1; i <= m; i++) {
    s = 0;
    for (j = 1; j <= n; j++) s = s * 2 + (a[j][i] == '1');
    f[0][s]++;
  }
  for (i = 1; i <= n; i++) {
    i0 = i % 3;
    i1 = (i + 2) % 3;
    i2 = (i + 1) % 3;
    for (j = 0; j < (1 << n); j++) {
      f[i0][j] = 0;
      for (k = 0; k < n; k++) f[i0][j] += f[i1][j ^ (1 << k)];
      f[i0][j] += (i - 2 - n) * f[i2][j];
      f[i0][j] /= i;
      g[j] += f[i0][j] * min(i, n - i);
    }
  }
  ans = n * m + 1;
  for (i = 0; i < (1 << n); i++) ans = min(ans, g[i]);
  printf("%d\n", ans);
  return 0;
}
