#include <bits/stdc++.h>
using namespace std;
const int mxk = 4e6 + 10;
long long n, m, len, a[mxk], b[mxk], c[mxk], col[mxk];
void FWT_xor(long long a[], int opt = 1) {
  for (int i = 1; i < len; i <<= 1)
    for (int p = i; p < len; p += (i << 1))
      for (int k = p; k < p + i; ++k)
        if (opt)
          a[k - i] = (a[k - i] + a[k]), a[k] = a[k - i] - (a[k] << 1);
        else
          a[k - i] = (a[k - i] + a[k]) >> 1, a[k] = a[k - i] - a[k];
}
string s[30];
int main() {
  cin >> n >> m;
  len = (1 << n);
  for (int i = 1; i <= n; ++i) cin >> s[i];
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < m; j++) col[j + 1] |= (s[i][j] - '0') << (i - 1);
  for (int i = 1; i <= m; i++) a[col[i]]++;
  for (int i = 0; i < len; i++) {
    for (int u = i; u; u ^= u & (-u)) ++b[i];
    b[i] = min(b[i], n - b[i]);
  }
  FWT_xor(a), FWT_xor(b);
  for (int i = 0; i < len; ++i) c[i] = a[i] * b[i];
  FWT_xor(c, 0);
  long long ans = 1e9;
  for (int i = 0; i < len; ++i) ans = min(ans, c[i]);
  cout << ans << endl;
}
