#include <bits/stdc++.h>
using namespace std;
const int UNDEF = -1;
const int INF = 1e9 + 4;
template <typename T>
inline bool chkmax(T& aa, T bb) {
  return aa < bb ? aa = bb, true : false;
}
template <typename T>
inline bool chkmin(T& aa, T bb) {
  return aa > bb ? aa = bb, true : false;
}
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
const int mn = 1e5;
const int mx = 1 << 20;
const int mk = 21;
int a[mn];
int f[2][mk][mx];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  memset(a, 0, sizeof a);
  for (int i = 0; i < n; i++) {
    int msk = 1 << i;
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      if (s[j] == '1') {
        a[j] |= msk;
      }
    }
  }
  memset(f, 0, sizeof f);
  int cur = 0, nxt = 1;
  for (int j = 0; j < m; j++) f[cur][0][a[j]]++;
  int mz = 1 << n;
  for (int b = 0; b < n; b++) {
    for (int k = 0; k <= n; k++)
      for (int z = 0; z < mz; z++) f[nxt][k][z] = f[cur][k][z];
    int msk = 1 << b;
    for (int k = 0; k < n; k++) {
      for (int z = 0; z < mz; z++) {
        f[nxt][k + 1][z ^ msk] += f[cur][k][z];
      }
    }
    swap(cur, nxt);
  }
  int ans = INF;
  for (int z = 0; z < mz; z++) {
    int cand = 0;
    for (int k = 0; k <= n; k++) {
      cand += min(k, n - k) * f[cur][k][z];
    }
    chkmin(ans, cand);
  }
  printf("%d\n", ans);
}
