#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "Possible" : "Impossible");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  x += y;
  if (x >= mod) x -= mod;
}
void et() {
  puts("-1");
  exit(0);
}
inline void FWT_xor(long long *A, const int fla, int length) {
  for (int i = 1; i < length; i <<= 1)
    for (int j = 0; j < length; j += (i << 1))
      for (int k = 0; k < i; k++) {
        long long x = A[j + k], y = A[j + k + i];
        A[j + k] = x + y;
        A[j + k + i] = x - y;
        if (fla == -1) {
          A[j + k] /= 2;
          A[j + k + i] /= 2;
        }
      }
}
const int MN = 1 << 20;
char s[20][100055];
long long cnt[MN], A[MN], B[MN], pc[MN], dp[21][MN];
void fmain() {
  scanf("%d%d", &n, &m);
  int N = 1 << n;
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    scanf("%s", s[i]);
  }
  for (int(j) = 0; (j) < (int)(m); (j)++) {
    int x = 0;
    for (int(i) = 0; (i) < (int)(n); (i)++)
      if (s[i][j] == '1') x += 1 << i;
    cnt[x]++;
  }
  for (int(i) = 0; (i) < (int)(N); (i)++) {
    A[i] = cnt[i];
    pc[i] = __builtin_popcount(i);
  }
  FWT_xor(A, 1, N);
  for (int(i) = 0; (i) < (int)(n + 1); (i)++) {
    for (int(j) = 0; (j) < (int)(N); (j)++) B[j] = (pc[j] == i) ? 1 : 0;
    FWT_xor(B, 1, N);
    for (int(j) = 0; (j) < (int)(N); (j)++) B[j] = A[j] * B[j];
    FWT_xor(B, -1, N);
    for (int(j) = 0; (j) < (int)(N); (j)++) dp[i][j] = B[j];
  }
  int ans = (1 << 30);
  for (int(j) = 0; (j) < (int)(N); (j)++) {
    int tt = 0;
    for (int(i) = 0; (i) < (int)(n + 1); (i)++) {
      tt += dp[i][j] * min(i, n - i);
    }
    ans = min(ans, tt);
  }
  printf("%d\n", ans);
}
int main() {
  fmain();
  return 0;
}
