#include <bits/stdc++.h>
using namespace std;
long long a, b;
char A[20][101010];
vector<long long> computeJ(vector<long long> x) {
  int n = x.size();
  if (n == 1) return x;
  vector<long long> x0(x.begin(), x.begin() + n / 2);
  vector<long long> x1(x.begin() + n / 2, x.end());
  x0 = computeJ(x0);
  x1 = computeJ(x1);
  for (int i = 0; i < n / 2; i++) {
    x[i] = x0[i] + x1[i];
    x[i + n / 2] = x0[i] - x1[i];
  }
  return x;
}
vector<long long> mulS(vector<long long> x) {
  int n = x.size();
  if (n == 1) return x;
  vector<long long> x0(x.begin(), x.begin() + n / 2);
  vector<long long> x1(x.begin() + n / 2, x.end());
  x0 = mulS(x0);
  x1 = mulS(x1);
  for (int i = 0; i < n / 2; i++) {
    x[i] = x0[i] + x1[i];
    x[i + n / 2] = x0[i] - x1[i];
  }
  return x;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    scanf("%s", A[i]);
  }
  vector<long long> J(1 << n);
  for (int i = 0; i < 1 << n; i++) {
    int c = __builtin_popcount(i);
    J[i] = min(c, n - c);
  }
  J = computeJ(J);
  vector<long long> x(1 << n);
  for (int j = 0; j < m; j++) {
    int y = 0;
    for (int i = 0; i < n; i++) {
      if (A[i][j] == '1') y |= 1 << i;
    }
    x[y]++;
  }
  x = mulS(x);
  for (int i = 0; i < 1 << n; i++) {
    x[i] *= J[i];
  }
  x = mulS(x);
  long long ans = *min_element(x.begin(), x.end()) >> n;
  cout << ans << endl;
}
