#include <bits/stdc++.h>
using namespace std;
char s[21][100100];
int n, m, ans = 1e9, all, inv, a[100100], bit[1100000], is[21][1100000],
          f[21][1100000], tf[2][1100000];
int power(int a, int k) {
  int ret = 1;
  while (k) {
    if (k & 1) ret = 1LL * ret * a % 1000000007;
    a = 1LL * a * a % 1000000007;
    k >>= 1;
  }
  return ret;
}
void make(int &f, int v) {
  f = v;
  if (f > 1000000007) f -= 1000000007;
  if (f < 1000000007) f += 1000000007;
}
void FWT(int *a, int t) {
  int pre, cur = 0;
  for (int i = 0; i <= all; i++) tf[0][i] = a[i];
  for (int i = 0; i <= n - 1; i++) {
    pre = cur, cur ^= 1;
    for (int s = 0; s <= all; s++)
      if (!(s >> i & 1)) {
        int l = tf[pre][s], r = tf[pre][s | (1 << i)];
        tf[cur][s] = (l + r) % 1000000007;
        tf[cur][s | (1 << i)] = (l + 1000000007 - r) % 1000000007;
      }
  }
  if (t)
    for (int i = 0; i <= all; i++)
      tf[cur][i] = 1LL * tf[cur][i] * inv % 1000000007;
  for (int i = 0; i <= all; i++) a[i] = tf[cur][i];
}
int main() {
  scanf("%d%d", &n, &m);
  all = (1 << n) - 1;
  inv = power(power(2, 1000000007 - 2), n);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) a[i] = (a[i] << 1) + s[j][i] - '0';
  for (int i = 1; i <= all; i++) bit[i] = bit[i >> 1] + (i & 1);
  for (int i = 1; i <= m; i++) f[0][a[i]]++;
  for (int i = 0; i <= all; i++) is[bit[i]][i] = 1;
  FWT(f[0], 0);
  for (int i = 1; i <= n; i++) {
    FWT(is[i], 0);
    for (int j = 0; j <= all; j++)
      f[i][j] = 1LL * f[0][j] * is[i][j] % 1000000007;
    FWT(f[i], 1);
  }
  for (int i = 0; i <= all; i++) {
    int tmp = 0;
    for (int j = 0; j <= n; j++) tmp += min(j, n - j) * f[j][i];
    ans = min(ans, tmp);
  }
  printf("%d\n", ans);
}
