#include <bits/stdc++.h>
using namespace std;
int bit[100005], cnt[(1 << 21)];
int dp[(1 << 9)][25];
int rt[(1 << 9)][25];
char str[100005];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", &str);
    for (int j = 0; j < m; j++)
      if (str[j] == '1') bit[j] |= 1 << i;
  }
  cnt[0] = 0;
  for (int S = 1; S < (1 << 21); S++) {
    int T = S & (S - 1);
    cnt[S] = cnt[T] + 1;
  }
  int st = min(n, 13);
  int zan = n - st;
  int lim = n / 2;
  int ret = n * m;
  for (int S = 0; S < 1 << st; S++) {
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < m; i++) {
      int s = bit[i] >> st;
      int t = bit[i] - (s << st);
      t ^= S;
      dp[s][cnt[t]]++;
    }
    for (int i = 0; i < 1 << zan; i++) {
      for (int j = 1; j <= st; j++) {
        rt[i][j] = dp[i][j] * j;
        dp[i][j] += dp[i][j - 1];
        rt[i][j] += rt[i][j - 1];
      }
    }
    for (int T = 0; T < 1 << zan; T++) {
      int sum = 0;
      for (int i = 0; i < 1 << zan; i++) {
        int ft = i ^ T;
        ft = cnt[ft];
        sum += (n - ft) * dp[i][st] - rt[i][st];
        if (ft <= lim)
          sum += (2 * ft - n) * dp[i][lim - ft] + 2 * rt[i][lim - ft];
      }
      ret = min(ret, sum);
    }
  }
  printf("%d\n", ret);
  return 0;
}
