#include <bits/stdc++.h>
using namespace std;
const int inf = 987654321;
const long long int INF = 123456789987654321;
FILE *fin, *fout;
int N, M;
vector<vector<char> > T;
vector<int> C;
vector<vector<int> > dp;
int main() {
  scanf("%d %d", &N, &M);
  T = vector<vector<char> >(N, vector<char>(M));
  for (int i = 0; i < N; i++) {
    scanf("\n");
    for (int j = 0; j < M; j++) {
      scanf("%c", &T[i][j]);
    }
  }
  C.resize(M);
  for (int i = 0; i < M; i++) {
    C[i] = 0;
    for (int j = 0; j < N; j++) {
      if (T[j][i] == '1') C[i] += (1 << j);
    }
  }
  dp = vector<vector<int> >(N + 1, vector<int>((1 << N), 0));
  for (int i = 0; i < M; i++) {
    dp[0][C[i]]++;
  }
  for (int i = 0; i < (1 << N); i++) {
    dp[1][i] = 0;
    for (int j = 0; j < N; j++) {
      dp[1][i] += dp[0][i ^ (1 << j)];
    }
  }
  for (int i = 2; i <= N; i++) {
    for (int j = 0; j < (1 << N); j++) {
      dp[i][j] = 0;
      for (int k = 0; k < N; k++) {
        dp[i][j] += dp[i - 1][j ^ (1 << k)];
      }
      dp[i][j] = ((i - 2 - N) * dp[i - 2][j] + dp[i][j]) / i;
    }
  }
  int mini = inf;
  for (int i = 0; i < (1 << N); i++) {
    int res = 0;
    for (int j = 0; j <= N; j++) {
      res += min(j, N - j) * dp[j][i];
    }
    mini = min(mini, res);
  }
  printf("%d", mini);
}
