#include <bits/stdc++.h>
using namespace std;
void getint(int &v) {
  char ch, fu = 0;
  for (ch = '*'; (ch < '0' || ch > '9') && ch != '-'; ch = getchar())
    ;
  if (ch == '-') fu = 1, ch = getchar();
  for (v = 0; ch >= '0' && ch <= '9'; ch = getchar()) v = v * 10 + ch - '0';
  if (fu) v = -v;
}
const int INF = 1e9 + 10;
char s[500010];
int pc[2000010], n, l, m, a[200010];
long long F[2000010], G[2000010], ans, H[2000010];
void fwt(long long *a, int tp) {
  for (int j = 0; j <= l - 1; ++j)
    for (int i = 0; i <= n - 1; ++i)
      if ((i >> j) & 1) {
        long long x = a[i ^ (1 << j)], y = a[i];
        a[i ^ (1 << j)] = (x + y) / (tp == 1 ? 1 : 2),
                    a[i] = (x - y) / (tp == 1 ? 1 : 2);
      }
}
int main() {
  pc[0] = 0;
  for (int i = 1; i <= 2000000; ++i) pc[i] = pc[i >> 1] + (i & 1);
  cin >> n >> m;
  for (int i = 0; i <= n - 1; ++i) {
    scanf("%s", s);
    for (int j = 0; j <= m - 1; ++j) a[j] |= (s[j] - '0') << i;
  }
  l = n;
  n = 1 << n;
  for (int j = 0; j <= m - 1; ++j) ++F[a[j]];
  for (int j = 0; j <= n - 1; ++j) G[j] = min(pc[j], l - pc[j]);
  fwt(F, 1);
  fwt(G, 1);
  for (int j = 0; j <= n - 1; ++j) H[j] = F[j] * G[j];
  fwt(H, -1);
  ans = INF;
  for (int j = 0; j <= n - 1; ++j) ans = min(ans, H[j]);
  cout << ans << endl;
  return 0;
}
