#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:60777216")
using namespace std;
int n, m;
int a[111111];
int a1[111111];
int a2[111111];
int nb[1 << 20];
const int N1 = 13;
int c[N1 + 1][1 << (20 - N1)];
int main() {
  cin >> n >> m;
  string s;
  getline(cin, s);
  for (int i = (0); i < (n); i++) {
    getline(cin, s);
    for (int j = (0); j < (m); j++)
      if (s[j] == '1') a[j] |= 1 << i;
  }
  for (int i = (0); i < (1 << 20); i++) nb[i] = nb[i / 2] + i % 2;
  int n1 = min(n, N1);
  int fn1 = (1 << n1) - 1;
  int n2 = n - n1;
  int t;
  int best = n * m;
  for (int i = (0); i < (m); i++) a1[i] = a[i] & fn1, a2[i] = a[i] >> n1;
  for (int m1 = (0); m1 < (1 << n1); m1++) {
    memset(c, 0, sizeof c);
    for (int j = (0); j < (m); j++) c[nb[a1[j] ^ m1]][a2[j]]++;
    for (int m2 = (0); m2 < (1 << n2); m2++) {
      int sum = 0;
      for (int fnb = (0); fnb < (n1 + 1); fnb++)
        for (int fm2 = (0); fm2 < (1 << n2); fm2++)
          if (c[fnb][fm2]) {
            t = fnb + nb[fm2 ^ m2];
            sum += c[fnb][fm2] * min(n - t, t);
          }
      best = min(best, sum);
    }
  }
  cout << best << endl;
  return 0;
}
