#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
char s[22][maxn];
int n, m;
long long d[22][1 << 20];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = (0); i <= (n - 1); ++i) scanf("%s", s[i]);
  for (int j = (0); j <= (m - 1); ++j) {
    int num = 0;
    for (int i = (0); i <= (n - 1); ++i) num = (num << 1) + s[i][j] - '0';
    d[0][num]++;
  }
  for (int k = (1); k <= (n); ++k) {
    for (int s = (0); s <= ((1 << n) - 1); ++s) {
      if (k >= 2) d[k][s] = (k - 2 - n) * d[k - 2][s];
      for (int j = (0); j <= (n - 1); ++j) d[k][s] += d[k - 1][s ^ (1 << j)];
      d[k][s] /= k;
    }
  }
  long long ans = n * m;
  for (int s = (0); s <= ((1 << n) - 1); ++s) {
    long long res = 0;
    for (int k = (0); k <= (n); ++k) res += min(k, n - k) * d[k][s];
    ans = min(ans, res);
  }
  printf("%lld\n", ans);
  return 0;
}
