#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int Res = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') f = (ch == '-' ? -f : f), ch = getchar();
  while (ch >= '0' && ch <= '9') Res = Res * 10 + ch - '0', ch = getchar();
  return Res * f;
}
int N, M, len, S[100005];
long long Cnt[1048579], Num[1048579], Ans = 1e18;
char Ch[100005];
void FWT(long long *A, int opt) {
  for (int i = 1; i < len; i <<= 1) {
    for (int j = 0, p = i << 1; j < len; j += p) {
      for (int k = 0; k < i; k++) {
        long long x = A[j + k], y = A[i + j + k];
        A[j + k] = x + y;
        A[i + j + k] = x - y;
        if (!opt) A[j + k] /= 2, A[i + j + k] /= 2;
      }
    }
  }
}
int main() {
  N = read();
  M = read();
  for (int i = 0; i < (1 << N); i++) {
    int C1 = 0, C0 = 0;
    for (int j = 0; j < N; j++)
      if ((i >> j) & 1)
        C1++;
      else
        C0++;
    Cnt[i] = min(C1, C0);
  }
  for (int i = 1; i <= N; i++) {
    scanf("%s", Ch + 1);
    for (int j = 1; j <= M; j++) S[j] = (S[j] << 1) + Ch[j] - '0';
  }
  for (int i = 1; i <= M; i++) Num[S[i]]++;
  len = 1 << N;
  FWT(Cnt, 1);
  FWT(Num, 1);
  for (int i = 0; i < len; i++) Num[i] = Num[i] * Cnt[i];
  FWT(Num, 0);
  for (int i = 0; i < len; i++) Ans = min(Ans, Num[i]);
  printf("%lld\n", Ans);
  return 0;
}
