#include <bits/stdc++.h>
const int MN = 1100000 + 5, P = 998244353, inv2 = 499122177;
using namespace std;
template <typename T>
inline T &IN(T &in) {
  in = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) in = in * 10 + c - '0', c = getchar();
  return in *= f;
}
int n, m, N;
long long ans;
char s[MN];
long long a[MN], b[MN], c[MN], w[MN];
void fwt(long long *a, int n, int f) {
  for (int i = 2; i <= n; i <<= 1)
    for (int j = 0, d = i / 2; j < n; j += i)
      for (int k = 0; k < d; ++k) {
        long long x = a[j + k], y = a[j + k + d];
        a[j + k] = (x + y) % P, a[j + k + d] = (x - y + P) % P;
        if (f == -1)
          a[j + k] = a[j + k] * inv2 % P,
                a[j + k + d] = a[j + k + d] * inv2 % P;
      }
}
void input() {
  IN(n), IN(m);
  N = 1 << n;
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s + 1);
    for (int j = 1; j <= m; ++j) c[j] += (s[j] - '0') << i - 1;
  }
  for (int i = 1; i <= m; ++i) a[c[i]]++;
  for (int i = 0; i < N; ++i) b[i] = b[i >> 1] + (i & 1);
  for (int i = 0; i < N; ++i) b[i] = min(b[i], n - b[i]);
  fwt(a, N, 1), fwt(b, N, 1);
  for (int i = 0; i < N; ++i) c[i] = a[i] * b[i] % P;
  fwt(c, N, -1);
  ans = LLONG_MAX;
  for (int i = 0; i < N; ++i) ans = min(ans, c[i]);
  printf("%lld\n", ans);
}
int main() {
  input();
  return 0;
}
