#include <bits/stdc++.h>
using namespace std;
const long long N = 20, M = 998244353, Inv = M / 2 + 1;
long long n, m, cnt[1 << N], g[1 << N];
char s[N][1 << N];
inline void fwt(long long y[], long long m, long long opt) {
  for (long long i = 1; i < 1 << m; i <<= 1)
    for (long long j = 0, p = i << 1; j < 1 << m; j += p)
      for (long long k = j; k < j + i; k++) {
        long long u = y[k], v = y[k + i];
        y[k] = u + v;
        if (y[k] >= M) y[k] -= M;
        y[k + i] = u - v;
        if (y[k + i] < 0) y[k + i] += M;
        if (opt == -1) y[k] = (y[k] * Inv) % M, y[k + i] = (y[k + i] * Inv) % M;
      }
}
signed main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 0; i < n; i++) scanf("%s", s[i]);
  for (long long i = 0; i < m; i++) {
    long long val = 0;
    for (long long j = 0; j < n; j++)
      if (s[j][i] == '1') val += 1 << j;
    cnt[val]++;
  }
  for (long long i = 0; i < 1 << n; i++) {
    long long cnt = 0;
    for (long long j = 0; j < n; j++)
      if ((1 << j) & i) cnt++;
    g[i] = min(cnt, n - cnt);
  }
  fwt(cnt, n, 1);
  fwt(g, n, 1);
  for (long long i = 0; i < 1 << n; i++) (cnt[i] *= g[i]) %= M;
  fwt(cnt, n, -1);
  long long ans = 1e9;
  for (long long i = 0; i < 1 << n; i++) ans = min(ans, cnt[i]);
  printf("%lld\n", ans);
}
