#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int MAXN = 1000006;
char S[20][MAXN];
int W[MAXN * 2];
int dp[11][1 << 20];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (n); ++i) scanf("%s", S[i]);
  int qs = 0;
  int BIG = 1 << n;
  for (int i = 0; i < (m); ++i) {
    int e = 0;
    for (int j = 0; j < (n); ++j)
      if (S[j][i] == '1') e |= 1 << j;
    W[qs++] = e;
    W[qs++] = e ^ (BIG - 1);
  }
  for (int i = 0; i < (2 * m); ++i) dp[0][W[i]]++;
  for (int bit = 0; bit < (n); ++bit)
    for (int k = 9; k >= 0; --k)
      for (int mask = 0; mask < (BIG); ++mask)
        dp[k + 1][mask] += dp[k][mask ^ (1 << bit)];
  int ret = m * n;
  for (int mask = 0; mask < (BIG); ++mask) {
    int t = 0;
    for (int i = 0; i < (n / 2); ++i) t += dp[i][mask] * i;
    t += dp[n / 2][mask] * (n / 2) / (n % 2 == 0 ? 2 : 1);
    ret = min(ret, t);
  }
  printf("%d\n", ret);
  return 0;
}
