#include <bits/stdc++.h>
using namespace std;
const int N = 2000000 + 7;
const int M = 26;
const int mod = 999983;
const int inf = 1e9 + 7;
const double pi = acos(-1);
const int maxn = N * 2;
const double PI = acos(-1);
int n, m;
int a[N];
int dp[22][N];
string s;
void solve() {
  cin >> n >> m;
  for (int i = (0); i < (n); i++) {
    cin >> s;
    for (int j = (0); j < (m); j++) {
      int u = s[j] - '0';
      a[j] = (a[j] << 1) | u;
    }
  }
  for (int i = (0); i < (m); i++) {
    dp[0][a[i]]++;
  }
  for (int k = (1); k < (n + 1); k++) {
    for (int mask = (0); mask < (1 << n); mask++) {
      if (k >= 2) dp[k][mask] = (k - 2 - n) * dp[k - 2][mask];
      for (int p = (0); p < (n); p++) dp[k][mask] += dp[k - 1][mask ^ (1 << p)];
      dp[k][mask] /= k;
    }
  }
  int ans = inf;
  for (int mask = (0); mask < (1 << n); mask++) {
    int cur = 0;
    for (int k = (0); k < (n + 1); k++) cur += min(k, n - k) * dp[k][mask];
    ans = min(ans, cur);
  }
  cout << ans;
}
int main() {
  int T = 1;
  for (int i = (1); i < (T + 1); i++) {
    solve();
  }
}
