#include <bits/stdc++.h>
using namespace std;
const int MX = 1 << 20 | 1;
int n, m;
char s0[MX];
int a[MX][21];
long long F[MX], G[MX];
void FWT(long long a[], int n) {
  long long x, y;
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += (i << 1))
      for (int k = j; k < j + i; k++)
        x = a[k + i], y = a[k], a[k] = y + x, a[k + i] = y - x;
}
void NFWT(long long a[], int n) {
  long long x, y;
  for (int i = 1; i < n; i <<= 1)
    for (int j = 0; j < n; j += (i << 1))
      for (int k = j; k < j + i; k++)
        x = a[k + i], y = a[k], a[k] = (y + x) >> 1, a[k + i] = (y - x) >> 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", s0);
    for (int j = 0; j < m; j++) a[j][i] = s0[j] - '0';
  }
  for (int i = 0; i < m; i++) {
    int tmp = 0;
    for (int j = 0; j < n; j++) tmp |= (a[i][j] << j);
    F[tmp]++;
  }
  for (int i = 0; i < (1 << n); i++) {
    int tmp = i, res = 0;
    while (tmp) {
      res += tmp & 1;
      tmp >>= 1;
    }
    G[i] = min(res, n - res);
  }
  FWT(F, 1 << n);
  FWT(G, 1 << n);
  for (int i = 0; i < (1 << n); i++) F[i] *= G[i];
  NFWT(F, 1 << n);
  long long ans = 0x3f3f3f3f3f3f3f3fLL;
  for (int i = 0; i < (1 << n); i++) ans = min(ans, F[i]);
  printf("%lld", ans);
  return 0;
}
