#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
const int MX = 100005;
int c[MX];
int dp[1 << 20][22];
int main() {
  int n, m, x;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%1d", &x);
      if (x) c[j] |= (1 << i);
    }
  }
  int mx = (1 << n) - 1;
  for (int i = 0; i < m; i++) dp[c[i]][0]++;
  for (int k = 1; k <= n; k++) {
    for (int m = 0; m <= mx; m++) {
      for (int p = 0; p < n; p++) {
        int s = m ^ (1 << p);
        for (int i = 1; i <= k; i++) {
          if (i & 1)
            dp[m][k] += dp[s][k - i];
          else
            dp[m][k] -= dp[m][k - i];
        }
      }
      dp[m][k] /= k;
    }
  }
  int k = n >> 1, ans = n * m;
  for (int m = 0; m < mx; m++) {
    int s = 0;
    for (int i = 0; i <= n; i++) {
      s += min(i, n - i) * dp[m][i];
    }
    ans = min(ans, s);
  }
  printf("%d\n", ans);
  return 0;
}
