#include <bits/stdc++.h>
using namespace std;
template <class T>
class IsIterable__ {
  static void f(...);
  template <class U>
  static typename U::const_iterator f(const U &);

 public:
  const static bool value =
      !std::is_same<void, decltype(f(std::declval<T>()))>::value;
};
template <class F, class S>
ostream &operator<<(ostream &o, const pair<F, S> &p) {
  return o << "(" << p.first << ", " << p.second << ")";
}
template <class C>
void O__(ostream &o, const C &c) {
  bool f = 1;
  for (const auto &x : c) {
    if (!f) {
      o << ", ";
    }
    if (IsIterable__<decltype(x)>::value) {
      o << "\n";
    }
    f = 0;
    o << x;
  }
}
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "[";
  O__(o, v);
  o << "]";
  return o;
}
template <class T, class V>
ostream &operator<<(ostream &o, const map<T, V> &v) {
  o << "{";
  O__(o, v);
  o << "}";
  return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T> &v) {
  o << "{";
  O__(o, v);
  o << "}";
  return o;
}
const double PI = 3.1415926535897932384626433832795;
const double EPS = 1e-9;
const int INF = std::numeric_limits<int>::max();
const long long LLINF = std::numeric_limits<long long>::max();
int dp[21][1 << 20];
int distances[1 << 20];
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<string> field(n);
  for (int i = 0; i < n; ++i) {
    cin >> field[i];
  }
  for (int i = 0; i < m; ++i) {
    int mask = 0;
    for (int j = 0; j < n; ++j) {
      if (field[j][i] == '0') {
        mask ^= 1 << j;
      }
    }
    dp[0][mask] += 1;
  }
  for (size_t bit = 1; bit < (1 << n); bit *= 2) {
    for (int d = n - 1; d >= 0; --d) {
      for (int mask = 0; mask < (1 << n); ++mask) {
        dp[d + 1][mask ^ bit] += dp[d][mask];
      }
    }
  }
  vector<int> u(n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (field[i][j] == '1') {
        u[i] += 1;
      }
    }
  };
  ;
  for (int mask = 0; mask < (1 << n); ++mask) {
    for (int i = 0; i < n; ++i) {
      distances[mask] += (mask & (1 << i)) ? m - u[i] : u[i];
    }
  }
  int res = INF;
  for (int mask = 0; mask < (1 << n); ++mask) {
    int steps = 0;
    for (int d = 0; d <= n; ++d) {
      if (d < n - d) {
        steps += dp[d][mask] * (n - d - d);
      }
    }
    if (steps > 0) {
    }
    res = min(res, distances[mask] - steps);
  }
  cout << res << "\n";
  return 0;
}
