#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 21) + 10;
long long a[N], b[N], tp[N];
void dft(long long *a, int l, int r, long long *b) {
  int mid = (l + r) >> 1;
  if (l == r) return;
  dft(a, l, mid, b);
  dft(a, mid + 1, r, b);
  for (int x = l, y = mid + 1; x <= mid; x++, y++) {
    b[x] = a[x] + a[y];
    b[y] = a[x] - a[y];
  }
  for (int i = l; i <= r; i++) a[i] = b[i];
}
int c[N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    char ch;
    int x = 0;
    for (int j = 1; j <= m; j++) {
      while (scanf("%c", &ch), ch != '0' && ch != '1')
        ;
      c[j] = c[j] * 2 + ch - '0';
    }
  }
  for (int i = 1; i <= m; i++) a[c[i]]++;
  swap(n, m);
  for (int i = 0; i <= (1 << m) - 1; i++) {
    for (int j = i; j; j ^= j & -j) b[i]++;
    b[i] = min(b[i], m - b[i]);
  }
  dft(a, 0, (1 << m) - 1, tp);
  dft(b, 0, (1 << m) - 1, tp);
  for (int i = 0; i <= (1 << m) - 1; i++) a[i] = a[i] * b[i];
  dft(a, 0, (1 << m) - 1, tp);
  long long mi = 1e18;
  for (int i = 0; i <= (1 << m) - 1; i++) mi = min(mi, a[i]);
  cout << (mi >> m);
}
