#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 1000;
long long f[maxn], t[maxn], a[maxn];
void FWT(int len, long long *c) {
  for (int l = 2; l <= len; l <<= 1) {
    for (int i = 0; i + l <= len; i += l) {
      for (int j = 0; j < (l >> 1); j++) {
        long long tmp1 = c[i + j], tmp2 = c[i + j + (l >> 1)];
        c[i + j] = tmp1 + tmp2;
        c[i + j + (l >> 1)] = tmp1 - tmp2;
      }
    }
  }
}
void IFWT(int len, long long *c) {
  for (int l = 2; l <= len; l <<= 1) {
    for (int i = 0; i + l <= len; i += l) {
      for (int j = 0; j < (l >> 1); j++) {
        long long tmp1 = c[i + j], tmp2 = c[i + j + (l >> 1)];
        c[i + j] = (tmp1 + tmp2) / 2;
        c[i + j + (l >> 1)] = (tmp1 - tmp2) / 2;
      }
    }
  }
}
char s[maxn];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = (1), iend = (n); i <= iend; i++) {
    scanf("%s", s + 1);
    for (int j = (1), jend = (m); j <= jend; j++) {
      if (s[j] == '1') a[j] |= 1 << (n - i);
    }
  }
  int len = (1 << n);
  for (int i = (1), iend = (m); i <= iend; i++) t[a[i]]++;
  for (int i = (0), iend = (len - 1); i <= iend; i++)
    f[i] = min(__builtin_popcount(i), n - __builtin_popcount(i));
  FWT(len, f);
  FWT(len, t);
  for (int i = (0), iend = (len - 1); i <= iend; i++) f[i] = f[i] * t[i];
  IFWT(len, f);
  long long mx = 1e18;
  for (int i = (0), iend = (len - 1); i <= iend; i++) mx = min(mx, f[i]);
  cout << mx;
  return 0;
}
