#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 10;
const double eps = 1e-6;
int n, m;
int sum, res;
int f[21][1 << 21], col[MAX];
char s[MAX];
int main() {
  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') col[j] |= (s[j] == '1') << i;
  }
  for (int i = 0; i < m; i++) f[0][col[i]]++;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 1 << n; j++) {
      sum = i < 2 ? 0 : (i - 2 - n) * f[i - 2][j];
      for (int k = 0; k < n; k++) sum += f[i - 1][j ^ (1 << k)];
      f[i][j] = sum / i;
    }
  }
  res = n * m;
  for (int i = 0; i < 1 << n; i++) {
    sum = 0;
    for (int j = 0; j <= n; j++) sum += (j < n - j ? j : n - j) * f[j][i];
    res = res < sum ? res : sum;
  }
  printf("%d", res);
  return 0;
}
