#include <bits/stdc++.h>
using namespace std;
char str[20][100005];
int dp[1 << 20][21];
int main() {
  int n, m;
  {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) scanf(" %s", str[i]);
    for (int j = 0; j < m; j++) {
      int val = 0;
      for (int i = 0; i < n; i++) {
        if (str[i][j] == '1') {
          val |= 1 << i;
        }
      }
      dp[val][0]++;
    }
  }
  for (int k = 1; k <= n; k++) {
    for (int mask = 0; mask < (1 << n); mask++) {
      for (int i = 0; i < n; i++) {
        dp[mask][k] += dp[mask ^ (1 << i)][k - 1];
      }
      if (k >= 2) {
        dp[mask][k] -= n * dp[mask][k - 2];
      }
      if (k >= 3) {
        dp[mask][k] += (k - 2) * dp[mask][k - 2];
      }
      dp[mask][k] /= k;
    }
  }
  int ans = int(1e9);
  for (int mask = 0; mask < (1 << n); mask++) {
    int cand = 0;
    for (int i = 0; i <= n; i++) {
      cand += min(i, n - i) * dp[mask][i];
    }
    ans = min(ans, cand);
  }
  printf("%d\n", ans);
}
