#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const long long LINF = (long long)1e18;
const long double PI = acos((long double)-1);
const long double EPS = 1e-9;
long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long fpow(long long n, long long k, int p = MOD) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
template <class T>
inline int chkmin(T& a, const T& val) {
  return a > val ? a = val, 1 : 0;
}
template <class T>
inline int chkmax(T& a, const T& val) {
  return a < val ? a = val, 1 : 0;
}
void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
void submod(int& a, int val, int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }
int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
const int maxn = 20;
const int maxm = 100010;
int n, m;
int a[maxn][maxm];
int f[1 << maxn];
int g[1 << maxn];
void XORFFT(int a[], int n, int p, int invert) {
  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 u = a[j + k], v = a[i + j + k];
        a[j + k] = u + v;
        if (a[j + k] >= p) a[j + k] -= p;
        a[i + j + k] = u - v;
        if (a[i + j + k] < 0) a[i + j + k] += p;
      }
    }
  }
  if (invert) {
    long long inv = fpow(n, p - 2, p);
    for (int i = 0; i < n; i++) a[i] = a[i] * inv % p;
  }
}
void solve() {
  cin >> n >> m;
  for (int i = (0); i < (n); i++) {
    string s;
    cin >> s;
    for (int j = (0); j < (m); j++) a[i][j] = s[j] - '0';
  }
  for (int i = (0); i < (1 << n); i++) {
    f[i] = __builtin_popcountll(i);
    chkmin(f[i], n - f[i]);
  }
  for (int i = (0); i < (m); i++) {
    int t = 0;
    for (int j = (0); j < (n); j++) t = (t << 1) + a[j][i];
    g[t]++;
  }
  XORFFT(f, 1 << n, MOD, 0);
  XORFFT(g, 1 << n, MOD, 0);
  for (int i = (0); i < (1 << n); i++) f[i] = mult(f[i], g[i]);
  XORFFT(f, 1 << n, MOD, 1);
  int ans = INF;
  for (int i = (0); i < (1 << n); i++) {
    chkmin(ans, f[i]);
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
