#include <bits/stdc++.h>
using namespace std;
int n, m;
long long sum[1 << 21], g[1 << 21], ans = 1e18;
char a[20][100005];
void FWT(long long *x) {
  for (int i = 1; i < (1 << n); i <<= 1)
    for (int j = 0; j < (1 << n); j += (i << 1))
      for (int k = 0; k < i; k++) {
        long long tx = x[j + k], ty = x[j + k + i];
        x[j + k] = tx + ty, x[j + k + i] = tx - ty;
      }
}
void UFWT(long long *x) {
  for (int i = 1; i < (1 << n); i <<= 1)
    for (int j = 0; j < (1 << n); j += (i << 1))
      for (int k = 0; k < i; k++) {
        long long tx = x[j + k], ty = x[j + k + i];
        x[j + k] = (tx + ty) / 2, x[j + k + i] = (tx - ty) / 2;
      }
}
int get(int num) {
  int cnt = 0;
  while (num) {
    if (num & 1) cnt++;
    num >>= 1;
  }
  return min(cnt, n - cnt);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", a[i] + 1);
  for (int i = 1; i <= m; i++) {
    int tmp = 0;
    for (int j = 1, k = 1; j <= n; j++, k <<= 1)
      tmp = tmp + (a[j][i] == '1' ? k : 0);
    sum[tmp]++;
  }
  for (int i = 0; i < (1 << n); i++) g[i] = get(i);
  FWT(sum), FWT(g);
  for (int i = 0; i < (1 << n); i++) sum[i] *= g[i];
  UFWT(sum);
  for (int i = 0; i < (1 << n); i++) ans = min(ans, sum[i]);
  printf("%lld\n", ans);
}
