#include <bits/stdc++.h>
using namespace std;
const long long linf = 1e18 + 5;
const int mod = (int)1e9 + 7;
const int logN = 17;
const int inf = 1e9;
const int N = 2e5 + 5;
int dp[21][1 << 20], n, m, a[N], x, y, z, t, p;
char c;
char get() {
  c = getchar();
  while (c > '1' || c < '0') c = getchar();
  return c;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      c = get();
      if (c == '1') a[j] |= (1 << i - 1);
    }
  }
  int res = inf;
  for (int i = 1; i <= m; i++) dp[0][a[i]]++;
  int all = (1 << n);
  for (int i = 0; i < n; i++)
    for (int diff = n; diff >= 1; diff--)
      for (int j = 0; j < all; j++) {
        dp[diff][j] += dp[diff - 1][(1 << i) ^ j];
      }
  for (int i = 0; i <= (1 << n) - 1; i++) {
    int ans = 0;
    for (int j = 0; j <= n; j++) ans += dp[j][i] * min(j, n - j);
    res = min(res, ans);
  }
  cout << res << '\n';
  return 0;
}
