#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20;
int n, m, S[N], cnt[N];
long long a[N], b[N];
char s[N];
void FWT(long long *a, int n) {
  for (int d = 1; d < 1 << n; d <<= 1)
    for (int i = 0; i < 1 << n; i += d << 1)
      for (int j = 0; j < d; j++) {
        long long x = a[i + j], y = a[i + j + d];
        a[i + j] = x + y;
        a[i + j + d] = x - y;
      }
}
void IFWT(long long *a, int n) {
  for (int d = 1; d < 1 << n; d <<= 1)
    for (int i = 0; i < 1 << n; i += d << 1)
      for (int j = 0; j < d; j++) {
        long long x = a[i + j], y = a[i + j + d];
        a[i + j] = (x + y) / 2;
        a[i + j + d] = (x - y) / 2;
      }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (int)(0); i <= (int)(n - 1); i++) {
    scanf("%s", s + 1);
    for (int j = (int)(1); j <= (int)(m); j++)
      if (s[j] == '1') S[j] |= 1 << i;
  }
  for (int i = (int)(1); i <= (int)(m); i++) a[S[i]]++;
  for (int i = (int)(0); i <= (int)((1 << n) - 1); i++)
    cnt[i] = cnt[i / 2] + (i & 1);
  for (int i = (int)(0); i <= (int)((1 << n) - 1); i++)
    b[i] = min(cnt[i], n - cnt[i]);
  FWT(a, n);
  FWT(b, n);
  for (int i = (int)(0); i <= (int)((1 << n) - 1); i++) a[i] *= b[i];
  IFWT(a, n);
  int ans = 1 << 30;
  for (int i = (int)(0); i <= (int)((1 << n) - 1); i++)
    ans = min(1ll * ans, a[i]);
  cout << ans << endl;
}
