#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2000005;
int D, N, M, a[MAXN];
char S[MAXN];
long long f[MAXN], g[MAXN], ans = 2147483647;
void FWT(long long* f, int X) {
  for (int l = 2; l <= N; l <<= 1)
    for (int i = 0; i < N; i += l)
      for (int j = 0; j < (l >> 1); ++j) {
        long long x = f[i + j], y = f[i + j + (l >> 1)];
        f[i + j] = x + y, f[i + j + (l >> 1)] = x - y;
        if (X == -1) f[i + j] /= 2, f[i + j + (l >> 1)] /= 2;
      }
}
int main() {
  scanf("%d%d", &D, &M), N = 1 << D;
  int cnt;
  for (int i = 0; i < D; ++i) {
    scanf("%s", S);
    for (int j = 0; j < M; ++j)
      if (S[j] == '1') a[j] |= 1 << i;
  }
  for (int i = 0; i < M; ++i) ++f[a[i]];
  for (int i = 0; i < N; ++i)
    cnt = __builtin_popcount(i), g[i] = min(cnt, D - cnt);
  FWT(f, 1), FWT(g, 1);
  for (int i = 0; i < N; ++i) f[i] = f[i] * g[i];
  FWT(f, -1);
  for (int i = 0; i < N; ++i) ans = min(ans, f[i]);
  printf("%lld\n", ans);
  return 0;
}
