#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  };
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - 48;
    ch = getchar();
  };
  return x * f;
}
long long n, m, g[21][100201], cot[1400021], dp[1400022], zt[1400201];
inline void FWTxor(long long *a, int id, int lim) {
  for (int len = 1; len < lim; len <<= 1) {
    for (int i = 0; i < lim; i += len << 1) {
      long long *a1 = a + i, *a2 = a1 + len;
      for (int j = 0; j < len; j++) {
        long long x = a1[j], y = a2[j];
        a1[j] = (x + y) / (id == 1 ? 1 : 2);
        a2[j] = (x - y) / (id == 1 ? 1 : 2);
      }
    }
  }
}
inline int getch() {
  char s = getchar();
  while (!isdigit(s)) s = getchar();
  return s - '0';
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      g[i][j] = getch();
    }
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      zt[i] |= (1 << j - 1) * g[j][i];
    }
  }
  for (int i = 0; i <= (1 << n); i++) {
    cot[i] = cot[i >> 1] + (i & 1);
  }
  for (int i = 0; i <= (1 << n); i++) {
    cot[i] = min(cot[i], n - cot[i]);
  }
  for (int i = 1; i <= m; i++) {
    dp[zt[i]]++;
  }
  FWTxor(dp, 1, 1 << n);
  FWTxor(cot, 1, 1 << n);
  for (int i = 0; i < (1 << n); i++) dp[i] *= cot[i];
  FWTxor(dp, -1, 1 << n);
  long long x = 999999999;
  for (int i = 0; i < (1 << n); i++) x = min(dp[i], x);
  cout << x << endl;
}
