#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void ckmax(T& x, T y) {
  x = (y > x ? y : x);
}
template <typename T>
inline void ckmin(T& x, T y) {
  x = (y < x ? y : x);
}
namespace Fread {
const int SIZE = 1 << 21;
char buf[SIZE], *S, *T;
inline char getchar() {
  if (S == T) {
    T = (S = buf) + fread(buf, 1, SIZE, stdin);
    if (S == T) return '\n';
  }
  return *S++;
}
}  // namespace Fread
namespace Fwrite {
const int SIZE = 1 << 21;
char buf[SIZE], *S = buf, *T = buf + SIZE;
inline void flush() {
  fwrite(buf, 1, S - buf, stdout);
  S = buf;
}
inline void putchar(char c) {
  *S++ = c;
  if (S == T) flush();
}
struct NTR {
  ~NTR() { flush(); }
} ztr;
}  // namespace Fwrite
namespace Fastio {
struct Reader {
  template <typename T>
  Reader& operator>>(T& x) {
    char c = Fread ::getchar();
    T f = 1;
    while (c < '0' || c > '9') {
      if (c == '-') f = -1;
      c = Fread ::getchar();
    }
    x = 0;
    while (c >= '0' && c <= '9') {
      x = x * 10 + (c - '0');
      c = Fread ::getchar();
    }
    x *= f;
    return *this;
  }
  Reader& operator>>(char& c) {
    c = Fread ::getchar();
    while (c == '\n' || c == ' ') c = Fread ::getchar();
    return *this;
  }
  Reader& operator>>(char* str) {
    int len = 0;
    char c = Fread ::getchar();
    while (c == '\n' || c == ' ') c = Fread ::getchar();
    while (c != '\n' && c != ' ') {
      str[len++] = c;
      c = Fread ::getchar();
    }
    str[len] = '\0';
    return *this;
  }
  Reader() {}
} cin;
const char endl = '\n';
struct Writer {
  template <typename T>
  Writer& operator<<(T x) {
    if (x == 0) {
      Fwrite ::putchar('0');
      return *this;
    }
    if (x < 0) {
      Fwrite ::putchar('-');
      x = -x;
    }
    static int sta[45];
    int top = 0;
    while (x) {
      sta[++top] = x % 10;
      x /= 10;
    }
    while (top) {
      Fwrite ::putchar(sta[top] + '0');
      --top;
    }
    return *this;
  }
  Writer& operator<<(char c) {
    Fwrite ::putchar(c);
    return *this;
  }
  Writer& operator<<(char* str) {
    int cur = 0;
    while (str[cur]) Fwrite ::putchar(str[cur++]);
    return *this;
  }
  Writer& operator<<(const char* str) {
    int cur = 0;
    while (str[cur]) Fwrite ::putchar(str[cur++]);
    return *this;
  }
  Writer() {}
} cout;
}  // namespace Fastio
const int MAXN = 20, MAXM = 1e5;
const int INF = 1e9;
const int MOD = 1e9 + 7;
inline int mod1(int x) { return x < MOD ? x : x - MOD; }
inline int mod2(int x) { return x < 0 ? x + MOD : x; }
inline void add(int& x, int y) { x = mod1(x + y); }
inline void sub(int& x, int y) { x = mod2(x - y); }
inline int pow_mod(int x, int i) {
  int y = 1;
  while (i) {
    if (i & 1) y = (long long)y * x % MOD;
    x = (long long)x * x % MOD;
    i >>= 1;
  }
  return y;
}
int inv_2;
int n, m;
char s[MAXN + 5][MAXM + 5];
int bitcnt[1 << MAXN];
int f[1 << MAXN], g[1 << MAXN];
void fwt_xor(int* a, int n, int flag) {
  for (int i = 1; i < n; i <<= 1) {
    for (int j = 0; j < n; j += (i << 1)) {
      for (int k = 0; k < i; ++k) {
        int x = a[j + k], y = a[i + j + k];
        if (flag == 1) {
          a[j + k] = mod1(x + y);
          a[i + j + k] = mod2(x - y);
        } else {
          a[j + k] = (long long)mod1(x + y) * inv_2 % MOD;
          a[i + j + k] = (long long)mod2(x - y) * inv_2 % MOD;
        }
      }
    }
  }
}
int main() {
  Fastio ::cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    Fastio ::cin >> (s[i] + 1);
  }
  for (int i = 1; i < (1 << n); ++i) {
    bitcnt[i] = bitcnt[i >> 1] + (i & 1);
    g[i] = min(bitcnt[i], n - bitcnt[i]);
  }
  for (int i = 1; i <= m; ++i) {
    int mask = 0;
    for (int j = 1; j <= n; ++j) {
      if (s[j][i] == '1') {
        mask |= (1 << (j - 1));
      }
    }
    f[mask]++;
  }
  inv_2 = pow_mod(2, MOD - 2);
  fwt_xor(f, 1 << n, 1);
  fwt_xor(g, 1 << n, 1);
  for (int i = 0; i < (1 << n); ++i) {
    f[i] = (long long)f[i] * g[i] % MOD;
  }
  fwt_xor(f, 1 << n, -1);
  int ans = INF;
  for (int i = 0; i < (1 << n); ++i) {
    ckmin(ans, f[i]);
  }
  Fastio ::cout << ans << Fastio ::endl;
  return 0;
}
