#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 n, m, x, c[MX];
int dp[1 << 20][22];
int sum[1 << 20][22];
int main() {
  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 s, mx = (1 << n) - 1;
  for (int i = 0; i < m; i++) {
    dp[c[i]][0]++;
    sum[c[i]][0]++;
  }
  for (int k = 1; k <= n; k++) {
    for (int m = 0; m <= mx; m++) {
      for (int p = 0; p < n; p++) {
        s = m ^ (1 << p);
        dp[m][k] += sum[s][k - 1] - ((k > 1) ? sum[m][k - 2] : 0);
      }
      dp[m][k] /= k;
      sum[m][k] = dp[m][k] + ((k > 1) ? sum[m][k - 2] : 0);
    }
  }
  int k = n >> 1, ans = n * m;
  for (int m = 0; m < mx; m++) {
    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;
}
