#include <bits/stdc++.h>
using namespace std;
const int iinf = 0x7fffffff;
const long long linf = ~(1LL << 63);
template <typename T>
inline T gcd(T a, T b) {
  if (a < b) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <typename C>
inline void sort(C& v) {
  sort(v.begin(), v.end());
}
inline void println(int u) { printf("%d\n", u); }
inline void printsp(int u) { printf("%d ", u); }
const int maxn = 100100;
int dp[22][1 << 20];
int n, m;
int data[maxn];
string s;
int main() {
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s;
    {
      int j = 0;
      for (auto c : s) {
        data[j] = (data[j] << 1) | (c - '0');
        j++;
      }
    }
  }
  for (int i = 0; i < m; i++) dp[0][data[i]]++;
  for (int k = 1; k < n + 1; k++) {
    for (int mask = 0; mask < (1 << n); mask++) {
      dp[k][mask] += k - 2 >= 0 ? (k - 2 - n) * dp[k - 2][mask] : 0;
      for (int p = 0; p < n; p++) {
        dp[k][mask] += dp[k - 1][mask ^ (1 << p)];
      }
      dp[k][mask] /= k;
    }
  }
  int ans = n * m;
  for (int mask = 0; mask < (1 << n); mask++) {
    int cnt = 0;
    for (int k = 0; k < n + 1; k++) {
      cnt += min(k, n - k) * dp[k][mask];
    }
    ans = min(cnt, ans);
  }
  cout << ans << endl;
  return 0;
}
