#include <bits/stdc++.h>
using namespace std;
const long long MAXN = (1 << 20) + 10;
const long long INF = 2e9;
const long long G = 3;
const double PI = acos(-1);
long long n, m, ans = INF;
long long a[MAXN], b[MAXN], popcount[MAXN];
char mp[21][(long long)1e5 + 10];
template <typename T>
inline void read(T &a) {
  a = 0;
  char c = getchar();
  long long f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    a = a * 10 + (c ^ 48);
    c = getchar();
  }
  a *= f;
}
void FWT(long long *s, long long opt) {
  for (long long mid = 1; mid < (1 << n); mid <<= 1)
    for (long long i = 0; i < (1 << n); i += (mid << 1))
      for (long long j = 0; j < mid; ++j) {
        long long x = s[i + j], y = s[i + j + mid];
        s[i + j] = x + y;
        s[i + j + mid] = x - y;
        if (opt == -1) s[i + j] >>= 1, s[i + j + mid] >>= 1;
      }
}
signed main() {
  read(n);
  read(m);
  for (long long i = 1; i <= n; ++i) scanf("%s", mp[i] + 1);
  for (long long i = 1; i <= m; ++i) {
    long long state = 0;
    for (long long j = 1; j <= n; ++j) {
      state <<= 1;
      state |= (bool)(mp[j][i] == '1');
    }
    a[state]++;
  }
  for (long long i = 0; i <= (1 << n); ++i)
    popcount[i] = popcount[i >> 1] + (i & 1);
  for (long long i = 0; i < (1 << n); ++i)
    b[i] = min(popcount[i], n - popcount[i]);
  FWT(a, 1);
  FWT(b, 1);
  for (long long i = 0; i < (1 << n); ++i) a[i] *= b[i];
  FWT(a, -1);
  for (long long i = 0; i < (1 << n); ++i) ans = min(ans, a[i]);
  printf("%lld\n", ans);
  return 0;
}
