#include <bits/stdc++.h>
using namespace std;
const int MaxN = 20 + 5, MaxM = 100000 + 5;
const int MaxV = 2000000 + 5;
const int Mod = 998244353, inv2 = 499122177;
const int INF = 0x7F7F7F7F;
int N, M;
int A[MaxN][MaxM];
int X[MaxV], Y[MaxV], Z[MaxV];
inline int add(int x, int y) { return (x += y) >= Mod ? x - Mod : x; }
inline int sub(int x, int y) { return (x -= y) < 0 ? x + Mod : x; }
inline int mul(int x, int y) { return 1LL * x * y % Mod; }
inline int getDigit() {
  char c;
  do c = getchar();
  while (c < '0' || c > '9');
  return c - '0';
}
void init() {
  scanf("%d %d", &N, &M);
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= M; ++j) A[i][j] = getDigit();
}
inline int Count(int S) {
  int cnt = 0;
  while (S) {
    cnt++;
    S -= (S & -S);
  }
  return cnt;
}
inline void FWT(int a[], int n) {
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += (i << 1))
      for (int k = 0; k < i; ++k) {
        int lson = a[j + k], rson = a[i + j + k];
        a[j + k] = add(lson, rson);
        a[i + j + k] = sub(lson, rson);
      }
}
inline void IFWT(int a[], int n) {
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += (i << 1))
      for (int k = 0; k < i; ++k) {
        int lson = a[j + k], rson = a[i + j + k];
        a[j + k] = mul(add(lson, rson), inv2);
        a[i + j + k] = mul(sub(lson, rson), inv2);
      }
}
void solve() {
  for (int i = 1; i <= M; ++i) {
    int S = 0;
    for (int j = 1; j <= N; ++j) S |= (A[j][i] << (j - 1));
    X[S]++;
  }
  for (int S = 0; S < (1 << N); ++S) Y[S] = min(Count(S), N - Count(S));
  FWT(X, 1 << N);
  FWT(Y, 1 << N);
  for (int i = 0; i < (1 << N); ++i) Z[i] = mul(X[i], Y[i]);
  IFWT(Z, 1 << N);
  int ans = INF;
  for (int i = 0; i < (1 << N); ++i) ans = min(ans, Z[i]);
  cout << ans << endl;
}
int main() {
  init();
  solve();
  return 0;
}
