#include <bits/stdc++.h>
using namespace std;
inline int Get() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m;
int s[25][100005];
long long f[1 << 20], g[1 << 20];
int Count(int s) {
  int ans = 0;
  for (; s; s >>= 1) ans += s & 1;
  return ans;
}
void FWT_xor(long long *a, int n, int flag) {
  for (int len = 2; len <= n; len <<= 1) {
    for (int mid = len >> 1, i = 0; i < n; i += len) {
      for (int j = 0; j < mid; j++) {
        long long u = a[i + j], v = a[i + j + mid];
        a[i + j] = u + v, a[i + j + mid] = u - v;
        if (flag == -1) a[i + j] /= 2, a[i + j + mid] /= 2;
      }
    }
  }
}
char t[100005];
void out(int s) {
  for (int i = 1; i <= 3; i++, s >>= 1) cout << (s & 1);
  cout << "\n";
}
int main() {
  n = Get(), m = Get();
  for (int i = 1; i <= n; i++) {
    scanf("%s", t + 1);
    for (int j = 1; j <= m; j++) s[i][j] = t[j] - '0';
  }
  for (int i = 1; i <= m; i++) {
    int now = 0;
    for (int j = 1; j <= n; j++) now = (now << 1) | s[j][i];
    g[now]++;
  }
  for (int s = 0; s < (1 << n); s++) {
    f[s] = Count(s);
    f[s] = min(f[s], n - f[s]);
  }
  FWT_xor(f, 1 << n, 1), FWT_xor(g, 1 << n, 1);
  for (int i = 0; i < (1 << n); i++) f[i] *= g[i];
  FWT_xor(f, 1 << n, -1);
  long long ans = 1e9;
  for (int i = 0; i < (1 << n); i++) ans = min(ans, f[i]);
  cout << ans;
  return 0;
}
