#include <bits/stdc++.h>
using namespace std;
char CRTBUFF[300000];
struct debugger {
  static void call(const char* it) {}
  template <typename T, typename... aT>
  static void call(const char* it, T a, aT... rest) {
    string b;
    for (; *it && *it != ','; ++it)
      if (*it != ' ') b += *it;
    cerr << b << "=" << a << " ";
    call(++it, rest...);
  }
};
int inv2;
long long add(long long a, long long b) {
  long long res = a + b;
  if (res >= 1000000007) res -= 1000000007;
  return res;
}
long long sub(long long a, long long b) { return add(1000000007, add(a, -b)); }
long long mul(long long a, long long b) { return (a * b) % 1000000007; }
void walsh_transform(long long* ar, int n) {
  if (n == 0) return;
  int i, j, m = n / 2, len;
  for (len = 1; 2 * len <= n; len <<= 1) {
    for (i = 0; i < n; i += 2 * len) {
      for (j = 0; j < len; j++) {
        long long x = ar[i + j], y = ar[i + j + len];
        ar[i + j] = add(x, y), ar[i + j + len] = sub(x, y);
      }
    }
  }
}
void inverse_walsh_transform(long long* ar, int n) {
  if (n == 0) return;
  int i, j, m = n / 2, len;
  for (len = 1; 2 * len <= n; len <<= 1) {
    for (i = 0; i < n; i += 2 * len) {
      for (j = 0; j < len; j++) {
        long long x = ar[i + j], y = ar[i + j + len];
        ar[i + j] = mul(add(x, y), inv2),
               ar[i + j + len] = mul(sub(x, y), inv2);
      }
    }
  }
}
long long modpow(long long x, long long e) {
  long long res = 1;
  while (e) {
    if (e & 1) res = mul(res, x);
    x = mul(x, x), e >>= 1;
  }
  return res;
}
const int lim = 1 << 21;
string s[30];
long long ones[lim + 10], freq[lim + 10], res[lim + 10];
void init() { inv2 = modpow(2, 1000000007 - 2); }
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  };
  init();
  int n, m;
  while (cin >> n >> m) {
    memset(freq, 0, sizeof(freq));
    memset(ones, 0, sizeof(ones));
    for (int i = (0); i < (n); i += (1)) cin >> s[i];
    for (int j = (0); j < (m); j += (1)) {
      int mask = 0;
      for (int i = (0); i < (n); i += (1))
        if (s[i][j] == '1') {
          mask = ((mask) | (1 << (i)));
        }
      freq[mask]++;
    }
    for (int i = (0); i < (lim); i += (1)) {
      int p = __builtin_popcount(i);
      ones[i] = min(p, n - p);
    }
    walsh_transform(ones, lim);
    walsh_transform(freq, lim);
    for (int i = (0); i < (lim); i += (1)) res[i] = mul(freq[i], ones[i]);
    inverse_walsh_transform(res, lim);
    long long ans = res[0];
    for (int i = (0); i < (1 << n); i += (1)) ans = min(ans, res[i]);
    cout << ans << "\n";
  }
}
