#include <bits/stdc++.h>
using namespace std;
long long n, m, f[1050000], a[1050000], b[1050000], mp[21][100005], ans;
void fwt(long long a[], long long n, long long f) {
  for (long long i = 1; i < 1 << n; i <<= 1) {
    for (long long t = 0; t < 1 << n; t++) {
      if (i & t) {
        long long x = a[t - i], y = a[t];
        a[t - i] = x + y;
        a[t] = x - y;
      }
    }
  }
  if (f == -1) {
    for (long long i = 0; i < 1 << n; i++) a[i] = a[i] / (1 << n);
  }
}
long long get(long long x) {
  long long num = 0;
  while (x) {
    if (x % 2 == 1) num++;
    x /= 2;
  }
  return num;
}
int main() {
  scanf("%lld%lld", &n, &m);
  ans = n * m;
  f[1] = 1;
  for (long long i = 2; i <= n; i++) {
    f[i] = f[i - 1] * 2;
  }
  for (long long i = 1; i <= n; i++) {
    for (long long t = 1; t <= m; t++) {
      char s;
      cin >> s;
      if (s == '1')
        mp[i][t] = 1;
      else
        mp[i][t] = 0;
    }
  }
  for (long long i = 1; i <= m; i++) {
    long long x = 0;
    for (long long t = 1; t <= n; t++) {
      if (mp[t][i] == 1) x += f[t];
    }
    a[x]++;
  }
  for (long long i = 0; i < 1 << n; i++) {
    long long x = get(i);
    b[i] = min(x, n - x);
  }
  fwt(a, n, 1);
  fwt(b, n, 1);
  for (long long i = 0; i < 1 << n; i++) {
    a[i] = a[i] * b[i];
  }
  fwt(a, n, -1);
  for (long long i = 0; i < 1 << n; i++) {
    ans = min(ans, a[i]);
  }
  printf("%lld", ans);
}
