#include <bits/stdc++.h>
using namespace std;
const int M = 2e6 + 10, N = 20;
int n, m, ans = 1e9, sum, ar[M], dp[2][N][(1LL << N)];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      ar[j] *= 2;
      if (s[j] == '1') ar[j]++;
    }
  }
  for (int i = 0; i < m; i++) dp[0][0][ar[i]]++;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int mask = 0; mask < (1LL << n); mask++) {
        if (!j)
          dp[i & 1LL][j][mask] = dp[(i - 1LL) & 1LL][j][mask];
        else
          dp[i & 1][j][mask] = dp[(i - 1) & 1][j][mask] +
                               dp[(i - 1) & 1][j - 1][mask ^ (1LL << (n - i))];
      }
    }
  }
  for (int mask = 0; mask < (1LL << n); mask++) {
    int tmp = 0;
    for (int i = 0; i <= n; i++) tmp += dp[n & 1][i][mask] * min(i, n - i);
    ans = min(ans, tmp);
  }
  cout << ans;
}
