#include <bits/stdc++.h>
using namespace std;
const int N = 20, M = 1e5 + 5;
int a[M], dp[(1 << N) + 5][N + 1][2], ans = N * M;
;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      char x;
      cin >> x;
      a[j] += (x == '1') * (1 << i);
    }
  for (int i = 0; i < m; i++) dp[a[i]][0][0]++;
  for (int j = 1; j <= n; j++)
    for (int mask = 0; mask < (1 << n); mask++)
      for (int i = 0; i <= j; i++) {
        dp[mask][i][j & 1] = dp[mask][i][(j - 1) & 1];
        if (i > 0)
          dp[mask][i][j & 1] += dp[mask ^ (1 << (j - 1))][i - 1][(j - 1) & 1];
      }
  for (int i = 0; i < (1 << n); i++) {
    int rtr = 0;
    for (int j = 0; j <= n; j++) rtr += dp[i][j][n & 1] * min(j, n - j);
    ans = min(ans, rtr);
  }
  cout << ans;
  return 0;
}
