#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read() {
  register T sum = 0;
  register char cc = getchar();
  int sym = 1;
  while (cc != '-' && (cc > '9' || cc < '0')) cc = getchar();
  if (cc == '-') sym = -1, cc = getchar();
  sum = sum * 10 + cc - '0';
  cc = getchar();
  while (cc >= '0' && cc <= '9') sum = sum * 10 + cc - '0', cc = getchar();
  return sym * sum;
}
template <typename T>
inline T read(T &a) {
  a = read<T>();
  return a;
}
template <typename T, typename... Others>
inline void read(T &a, Others &...b) {
  a = read(a);
  read(b...);
}
int n, m, val[100010], bits[1100000];
long long ans = 0x7fffffff, F[1100000], Q[1100000];
void FWT(long long *A, int len, int op = 1) {
  for (int i = 1; i < len; i <<= 1)
    for (int j = 0; j < len; j += i << 1)
      for (int k = j; k < j + i; k++) {
        long long x = A[k], y = A[k + i];
        A[k] = (x + y) / (op == -1 ? 2 : 1);
        A[k + i] = (x - y) / (op == -1 ? 2 : 1);
      }
}
int main() {
  read(n, m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      int x;
      scanf("%1d", &x);
      val[j] |= x << (i - 1);
    }
  for (int i = 1; i <= m; i++) Q[val[i]] += 1;
  for (int i = 1; i < (1 << n); i++) bits[i] = bits[i >> 1] + (i & 1);
  for (int i = 0; i < (1 << n); i++)
    F[i] = min(bits[i], bits[((1 << n) - 1) ^ i]);
  FWT(F, 1 << n);
  FWT(Q, 1 << n);
  for (int i = 0; i < (1 << n); i++) F[i] *= Q[i];
  FWT(F, 1 << n, -1);
  for (int i = 0; i < (1 << n); i++) ans = min(ans, F[i]);
  printf("%lld\n", ans);
  return 0;
}
