#include <bits/stdc++.h>
using namespace std;
const int MX = 20;
const int MM = 1e5 + 5;
int A[MM], n, m;
char S[MM];
long long F[1 << MX], G[1 << MX];
void fwt(long long F[], int n) {
  for (int i = 0; i < n; i++) {
    for (int s = 0; s < 1 << n; s++) {
      if (s >> i & 1) continue;
      long long l = F[s], r = F[s | (1 << i)];
      F[s] = l + r;
      F[s | (1 << i)] = l - r;
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", S);
    for (int j = 0; j < m; j++) {
      A[j] = A[j] << 1 | (S[j] - '0');
    }
  }
  for (int i = 0; i < m; i++) {
    F[A[i]] += 1;
  }
  for (int i = 0; i < 1 << n; i++) {
    int t = __builtin_popcount(i);
    G[i] = min(t, n - t);
  }
  fwt(F, n);
  fwt(G, n);
  for (int i = 0; i < 1 << n; i++) {
    F[i] = F[i] * G[i];
  }
  fwt(F, n);
  int ans = n * m, div = 1 << n;
  for (int i = 0; i < 1 << n; i++) {
    ans = min(ans, (int)(F[i] / div));
  }
  printf("%d\n", ans);
  return 0;
}
