#include <bits/stdc++.h>
const int N = (1 << 20) + 7;
void Xor(int n, long long *a, long long op) {
  long long x, y;
  for (int w = 2, l = 1; w <= n; w <<= 1, l <<= 1)
    for (int j = 0; j < n; j += w)
      for (int k = 0; k < l; k++)
        x = (a[j | k] + a[j | k | l]) / op, y = (a[j | k] - a[j | k | l]) / op,
        a[j | k] = x, a[j | k | l] = y;
}
int n, m;
long long a[N], f[N], g[N];
inline int min(int x, int y) { return x < y ? x : y; }
inline int lowbit(int x) { return -x & x; }
inline int count(int x) {
  int ret = 0;
  while (x) x -= lowbit(x), ret++;
  return ret;
}
int main() {
  scanf("%d%d", &n, &m);
  int ans = n * m;
  for (int i = 1; i <= n; i++) {
    char c;
    for (int j = 1; j <= m; j++) {
      c = getchar();
      while (c != '0' && c != '1') c = getchar();
      a[j] = (a[j] << 1) + c - '0';
    }
  }
  for (int i = 1; i <= m; i++) f[a[i]]++;
  m = 1 << n;
  for (int i = 0; i < m; i++) {
    int x = count(i);
    g[i] = min(n - x, x);
  }
  Xor(m, f, 1), Xor(m, g, 1);
  for (int i = 0; i < m; i++) f[i] = f[i] * g[i];
  Xor(m, f, 2);
  for (int i = 0; i < m; i++) ans = min(ans, f[i]);
  printf("%d", ans);
}
