#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chkmin(T& x, T y) {
  return x > y ? x = y, true : false;
}
template <class T>
inline bool chkmax(T& x, T y) {
  return x < y ? x = y, true : false;
}
inline long long read(void) {
  long long x, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (x = 0; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return x * f;
}
int n, m, S;
long long a[((1 << 20) + 1)], b[((1 << 20) + 1)], c[((1 << 20) + 1)];
void fwt(long long* a, int len) {
  if (len == 1) return;
  int s = len >> 1;
  fwt(a, s);
  fwt(a + s, s);
  for (int i = (0); i <= (s - 1); ++i) {
    long long x = a[i], y = a[i + s];
    a[i] = x + y;
    a[i + s] = x - y;
  }
}
void ifwt(long long* a, int len) {
  if (len == 1) return;
  int s = len >> 1;
  for (int i = (0); i <= (s - 1); ++i) {
    long long x = a[i], y = a[i + s];
    a[i] = x + y >> 1;
    a[i + s] = x - y >> 1;
  }
  ifwt(a, s);
  ifwt(a + s, s);
}
int main(void) {
  n = read();
  m = read();
  S = 1 << n;
  for (int i = (0); i <= (S - 1); ++i)
    a[i] = min(__builtin_popcount(i), n - __builtin_popcount(i));
  for (int i = (0); i <= (n - 1); ++i) {
    static char s[100005];
    scanf("%s", s);
    for (int j = (0); j <= (m - 1); ++j)
      if (s[j] != '0') c[j] |= 1 << i;
  }
  for (int i = (0); i <= (m - 1); ++i) b[c[i]]++;
  fwt(a, S);
  fwt(b, S);
  for (int i = (0); i <= (S - 1); ++i) a[i] *= b[i];
  ifwt(a, S);
  printf("%lld\n", *min_element(a, a + S));
  return 0;
}
