#include <bits/stdc++.h>
using namespace std;
int A[100005];
char s[100005];
long long a[1 << 20], c[1 << 20], tmp[1 << 20];
void tf(long long a[], int n) {
  if (n == 1) return;
  int x = n >> 1;
  tf(a, x);
  tf(a + x, x);
  for (int i = 0; i < x; ++i) {
    tmp[i] = a[i] - a[x + i];
    tmp[x + i] = a[i] + a[x + i];
  }
  for (int i = 0; i < n; ++i) a[i] = tmp[i];
}
void utf(long long a[], int n) {
  if (n == 1) return;
  int x = n >> 1;
  for (int i = 0; i < x; ++i) {
    tmp[i] = (a[i] + a[i + x]) / 2;
    tmp[i + x] = (a[i + x] - a[i]) / 2;
  }
  for (int i = 0; i < n; ++i) a[i] = tmp[i];
  utf(a, x);
  utf(a + x, x);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s);
    for (int j = 0; j < m; ++j) {
      if (s[j] == '1') {
        A[j] |= 1 << i;
      }
    }
  }
  for (int i = 0; i < m; ++i) ++a[A[i]];
  for (int i = 1; i < 1 << n; ++i) {
    c[i] = c[i >> 1] + (i & 1);
  }
  for (int i = 0; i < 1 << n; ++i) {
    c[i] = min(c[i], n - c[i]);
  }
  tf(a, 1 << n);
  tf(c, 1 << n);
  for (int i = 0; i < 1 << n; ++i) {
    a[i] = a[i] * c[i];
  }
  utf(a, 1 << n);
  printf("%I64d\n", *min_element(a, a + (1 << n)));
  return 0;
}
