#include <bits/stdc++.h>
using namespace std;
int dp[21][1050000];
int ti[100010];
char s[100010];
int main() {
  int i, j, m, n, x, y, t, k, mask, ans, sum;
  scanf("%d%d", &n, &m);
  memset(ti, 0, sizeof(ti));
  for (i = 1; i <= n; i++) {
    scanf("%s", s);
    for (j = 0; j < m; j++) ti[j] = ti[j] + (s[j] - '0') * (1 << (i - 1));
  }
  memset(dp, 0, sizeof(dp));
  for (i = 0; i < m; i++) dp[0][ti[i]]++;
  for (i = 1; i <= n; i++)
    for (mask = 0; mask < (1 << n); mask++) {
      sum = 0;
      if (i >= 2) sum = (i - 2 - n) * dp[i - 2][mask];
      for (j = 0; j < n; j++) sum += dp[i - 1][mask ^ (1 << j)];
      dp[i][mask] = sum / i;
    }
  ans = 2147483647;
  for (mask = 0; mask < (1 << n); mask++) {
    sum = 0;
    for (i = 0; i <= n; i++) sum += dp[i][mask] * min(i, n - i);
    if (sum < ans) ans = sum;
  }
  cout << ans;
}
