#include <bits/stdc++.h>
using namespace std;
long long f[2000005], g[2000005], res[2000005];
char str[25][100005];
namespace FWT {
void fwt(long long *arr, int n, bool inv = false) {
  for (int len = 1; len < n; len <<= 1) {
    for (int i = 0; i < n; i += len << 1) {
      for (int j = i; j < i + len; j++) {
        long long x = arr[j], y = arr[j + len];
        arr[j] = (x + y) / (inv + 1);
        arr[j + len] = (x - y) / (inv + 1);
      }
    }
  }
}
void mul(long long *a, long long *b, long long *res, int n) {
  fwt(a, n);
  fwt(b, n);
  for (int i = 0; i < n; i++) res[i] = a[i] * b[i];
  fwt(res, n, true);
}
}  // namespace FWT
inline int cnt(int x) {
  int res = 0;
  while (x) {
    x &= x - 1;
    res++;
  }
  return res;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", str[i]);
  for (int i = 0; i < m; i++) {
    int num = 0;
    for (int j = 0; j < n; j++) num = num << 1 | str[j][i] - '0';
    f[num]++;
  }
  for (int i = 0; i < 1 << n; i++) g[i] = min(cnt(i), n - cnt(i));
  FWT::mul(f, g, res, 1 << n);
  long long ans = 1e18;
  for (int i = 0; i < 1 << n; i++) ans = min(ans, res[i]);
  printf("%lld\n", ans);
  return 0;
}
