#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, M = 20 + 1;
int n, m, a[N], dp[(1 << 20)][M];
long long ans;
void input() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char ch;
      cin >> ch;
      bool x = ch - '0';
      a[j] += (1 << i) * x;
    }
  }
}
void solve() {
  for (int i = 0; i < m; i++) dp[a[i]][0]++;
  for (int i = 0; i < n; i++)
    for (int j = n; j; j--)
      for (int mask = 0; mask < (1 << n); mask++)
        dp[mask][j] += dp[mask ^ (1 << i)][j - 1];
  ans = 1e18;
  for (int mask = 0; mask < (1 << n); mask++) {
    long long res = 0;
    for (long long i = 0; i <= n; i++) res += min(i, n - i) * dp[mask][i];
    ans = min(ans, res);
  }
}
void output() { cout << ans << "\n"; }
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  input();
  solve();
  output();
}
