#include <bits/stdc++.h>
using namespace std;
void fwt(long long* a, long long L) {
  for (long long i = 2; i <= L; i <<= 1)
    for (long long j = 0; j < L; j += i)
      for (long long k = j; k < j + (i >> 1); ++k) {
        long long x = a[k] + a[k + (i >> 1)];
        long long y = a[k] - a[k + (i >> 1)];
        a[k] = x;
        a[k + (i >> 1)] = y;
      }
}
void ifwt(long long* a, long long L) {
  for (long long i = L; i >= 2; i >>= 1)
    for (long long j = 0; j < L; j += i)
      for (long long k = j; k < j + (i >> 1); ++k) {
        long long x = a[k] + a[k + (i >> 1)];
        long long y = a[k] - a[k + (i >> 1)];
        a[k] = x / 2;
        a[k + (i >> 1)] = y / 2;
      }
}
long long n, m, s[100010], ct[1 << 20];
long long L, a[1 << 20], b[1 << 20], c[1 << 20];
signed main() {
  cin >> n >> m;
  for (long long i = 1; i <= n; ++i) {
    char c = getchar();
    while (c < '0' || c > '9') c = getchar();
    for (long long j = 1; j <= m; ++j)
      s[j] = s[j] << 1 | (c == '1'), c = getchar();
  }
  L = (1 << n);
  for (long long i = 0; i <= L - 1; ++i)
    for (long long j = 1; j <= n; ++j) ct[i] += (i >> j - 1 & 1);
  for (long long i = 1; i <= m; ++i) b[s[i]]++;
  fwt(b, L);
  for (long long i = 0; i <= n; ++i) {
    memset(a, 0, sizeof a);
    for (long long j = 0; j <= L - 1; ++j)
      if (ct[j] == i) a[j] = min(i, n - i);
    fwt(a, L);
    for (long long j = 0; j <= L - 1; ++j) a[j] = a[j] * b[j];
    ifwt(a, L);
    for (long long j = 0; j <= L - 1; ++j) c[j] += a[j];
  }
  long long ans = n * m;
  for (long long i = 0; i <= L - 1; ++i) ans = min(ans, c[i]);
  cout << ans << endl;
}
