#include <bits/stdc++.h>
using namespace std;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const long long NLINF = 0xf7f7f7f7f7f7f7f7;
const int INF = 0x3f3f3f3f, NINF = 0xf7f7f7f7;
const int MOD1 = 1e9 + 7, MOD2 = 1e9 + 9;
const int N = 21, M = 1e5 + 10;
int n, m, ans = INF, col[M], dp[N][1 << 20];
char s[N][M];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf(" %s", s[i] + 1);
  for (int j = 1; j <= m; j++)
    for (int i = 1; i <= n; i++)
      if (s[i][j] == '1') col[j] |= (1 << (i - 1));
  for (int i = 1; i <= m; i++) dp[0][col[i]]++;
  for (int p = 0; p < n; p++) {
    for (int i = n; i; i--)
      for (int msk = 0; msk < (1 << n); msk++)
        dp[i][msk] += dp[i - 1][msk ^ (1 << p)];
  }
  for (int msk = 0; msk < (1 << n); msk++) {
    int cur = 0;
    for (int i = 0; i <= n; i++) cur += min(i, n - i) * dp[i][msk];
    ans = min(ans, cur);
  }
  printf("%d\n", ans);
}
