#include <bits/stdc++.h>
using namespace std;
const int maxn = 22;
const int maxp = 777 + (1 << (maxn - 2));
const int maxm = 1E5 + 77;
char S[maxm];
int N, M, _V[maxn][maxm], V[maxm], dp[maxn][maxp], ans = 1E9 + 7;
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; ++i) {
    scanf("%s", S);
    for (int j = 0; j < M; ++j) _V[i][j] = S[j] == '1' ? 1 : 0;
  }
  for (int j = 0; j < M; ++j)
    for (int i = 0, v = 1; i < N; ++i, v <<= 1) V[j] |= _V[i][j] ? v : 0;
  for (int i = 0; i < M; ++i) {
    ++dp[0][V[i]];
  }
  int tot = 1 << N;
  for (int i = 1; i <= N; ++i)
    for (int j = 0; j < tot; ++j) {
      if (i >= 3) dp[i][j] = dp[i - 2][j] * (i - 2);
      for (int p = 1; p < tot; p <<= 1) {
        for (int t = 1; t <= 2 && t <= i; ++t)
          dp[i][j] += (t & 1 ? 1 : -1) * dp[i - t][j ^ (t & 1 ? p : 0)];
      }
      dp[i][j] /= i;
    }
  for (int i = 0; i < tot; ++i) {
    int tans = 0;
    for (int j = 0; j <= N; ++j) tans += min(j, N - j) * dp[j][i];
    ans = min(ans, tans);
  }
  printf("%d\n", ans);
}
