#include <bits/stdc++.h>
using namespace std;
const int N = 20, M = 1e5 + 5, MOD = 998244353, S = (1 << N) + 5;
int n, m, n2;
long long a[S], b[S], ans = S;
char mp[N + 5][M];
inline void FWTxor(long long *a, int coe) {
  for (int len = 1; len < n2; len <<= 1)
    for (int st = 0; st < n2; st += len << 1)
      for (int d = 0; d < len; ++d) {
        long long ml = a[st + d], mr = a[st + d + len];
        a[st + d] = (ml + mr) * coe % MOD;
        a[st + d + len] = (ml - mr) * coe % MOD;
      }
}
inline int calc(int x) {
  int res = 0;
  while (x) res += (x & 1), x >>= 1;
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  n2 = 1 << n;
  for (int i = 1; i <= n; ++i) scanf("%s", &mp[i][1]);
  for (int i = 1, x; i <= m; ++i) {
    x = 0;
    for (int j = 1; j <= n; ++j) (x <<= 1) |= mp[j][i] - '0';
    ++a[x];
  }
  for (int i = 0; i < n2; ++i) b[i] = calc(i), b[i] = min(b[i], n - b[i]);
  FWTxor(a, 1);
  FWTxor(b, 1);
  for (int i = 0; i < n2; ++i) a[i] = a[i] * b[i] % MOD;
  FWTxor(a, (MOD + 1) / 2);
  for (int i = 0; i < n2; ++i) ans = min((a[i] + MOD) % MOD, ans);
  printf("%lld\n", ans);
  return 0;
}
