#include <bits/stdc++.h>
using namespace std;
const int N = 30;
const int M = 1E5 + 5;
const int S = 1 << 20;
int n, m, ans, dp[N][S], w, f[N][S], a[M];
char s[N][M];
void check() {
  memset(f, 0, sizeof(f));
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < m; j++) {
      int x = a[j] ^ i, y = 0;
      for (; x; x /= 2) y += (x & 1);
      f[y][i]++;
    }
    for (int j = 0; j <= n; j++)
      if (dp[j][i] != f[j][i]) cerr << j << " " << i << endl;
  }
}
int main() {
  cin >> n >> m;
  ans = n * m;
  for (int i = 1; i <= n; i++) scanf("%s", s[i]);
  for (int i = 0; i < m; i++) {
    for (int j = 1; j <= n; j++)
      if (s[j][i] == '1') a[i] += (1 << (j - 1));
    dp[0][a[i]]++;
  }
  for (int k = 0; k <= n; k++)
    for (int mask = 0; mask < (1 << n); mask++) {
      if (k) dp[k][mask] /= k;
      if (k <= 1)
        f[k][mask] = dp[k][mask];
      else
        f[k][mask] = f[k - 2][mask] + dp[k][mask];
      for (int p = 0; p < n; p++) {
        int u = mask ^ (1 << p);
        int &v = dp[k + 1][u];
        v += f[k][mask];
        if (k) v -= f[k - 1][u];
      }
    }
  for (int mask = 0; mask < (1 << n); mask++) {
    int sum = 0;
    for (int k = 0; k <= n; k++) {
      sum += min(k, n - k) * dp[k][mask];
    }
    ans = min(ans, sum);
  }
  cout << ans;
}
