#include <bits/stdc++.h>
using namespace std;
const int N = 100500;
char buf[N];
vector<long long> conv(const vector<long long>& v1,
                       const vector<long long>& v2) {
  if (v1.size() == 1 && v2.size() == 1) return {v1[0] * v2[0]};
  vector<long long> a1(v1.begin(), v1.begin() + v1.size() / 2);
  vector<long long> b1(v1.begin() + v1.size() / 2, v1.end());
  vector<long long> a2(v2.begin(), v2.begin() + v2.size() / 2);
  vector<long long> b2(v2.begin() + v2.size() / 2, v2.end());
  vector<long long> sum1(a1.size()), dif1(a1.size());
  for (int i = 0; i < a1.size(); i++)
    sum1[i] = a1[i] + b1[i], dif1[i] = a1[i] - b1[i];
  vector<long long> sum2(a2.size()), dif2(a2.size());
  for (int i = 0; i < a2.size(); i++)
    sum2[i] = a2[i] + b2[i], dif2[i] = a2[i] - b2[i];
  vector<long long> sum = conv(sum1, sum2);
  vector<long long> dif = conv(dif1, dif2);
  vector<long long> res(v1.size());
  for (int i = 0; i < sum.size(); i++) {
    res[i] = (sum[i] + dif[i]);
    res[i + res.size() / 2] = (sum[i] - dif[i]);
  }
  return res;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<long long> G(1 << n);
  vector<long long> P(1 << n);
  for (int i = 1; i < (1 << n); i++) P[i] = 1 + P[i & (i - 1)];
  for (int i = 0; i < (1 << n); i++) G[i] = min(P[i], n - P[i]);
  vector<long long> A(m);
  vector<long long> F(1 << n);
  for (int i = 0; i < n; i++) {
    scanf("%s", buf);
    for (int j = 0; j < m; j++) {
      if (buf[j] == '1') A[j] |= (1 << i);
    }
  }
  for (int x : A) F[x]++;
  vector<long long> res = conv(F, G);
  long long ans = *min_element(res.begin(), res.end());
  printf("%lld\n", ans >> n);
}
