#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1 << 20;
const long long lg = 23;
long long ans;
long long n, m;
long long num[maxn];
long long dp[lg][maxn];
void in();
void solve();
void out();
int main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  in();
  solve();
  out();
}
void in() {
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      char c;
      cin >> c;
      num[j] = num[j] * 2 + (c - '0');
    }
  }
}
void solve() {
  for (long long i = 0; i < m; i++) dp[0][num[i]]++;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j < (1 << n); j++) {
      for (long long k = 1; k <= min(i, 2ll); k++)
        for (long long l = 0; l < n; l++)
          dp[i][j] += ((k % 2) * 2 - 1) * dp[i - k][j ^ ((1 << l) * (k % 2))];
      if (i > 2) dp[i][j] = dp[i][j] + (i - 2) * dp[i - 2][j];
      dp[i][j] /= i;
    }
  }
  ans = m * n;
  for (long long i = 0; i < (1 << n); i++) {
    long long oof = 0;
    for (long long j = 0; j <= n; j++) oof += dp[j][i] * min(j, n - j);
    ans = min(ans, oof);
  }
}
void out() { cout << ans; }
