#include <bits/stdc++.h>
using namespace std;
const int M = 21, N = 2e6 + 7;
int n, m;
int t[N];
int dp[1048576 + 7][2][21];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      char c;
      cin >> c;
      t[j] *= 2;
      if (c == '1') t[j] += 1;
    }
  for (int j = 0; j < m; j++) dp[t[j]][0][0]++;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= i; j++)
      for (int msk = 0; msk < (1 << n); msk++) {
        dp[msk][i % 2][j] = dp[msk][(i - 1) % 2][j];
        if (j > 0)
          dp[msk][i % 2][j] += dp[(msk ^ (1 << (i - 1)))][(i - 1) % 2][j - 1];
      }
  int mn = m * n, res;
  for (int msk = 0; msk < (1 << n); msk++) {
    int tmp = 0;
    for (int j = 0; j <= n; j++) {
      tmp += dp[msk][n % 2][j] * min(j, n - j);
    }
    if (tmp < mn) {
      mn = tmp;
      res = msk;
    }
  }
  cout << mn;
  return 0;
}
