#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target( \
    "avx,avx2,fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int MOD = 1e9 + 7;
const int N = 1100000;
int kek;
int dps[20][N];
int dp[20][N];
int kol[N];
int koll[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),
      cout << fixed << setprecision(20);
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  string s[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  a.resize(m);
  kek = (1 << n) - 1;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      a[i] += (s[j][i] - '0') << j;
    }
  }
  for (int i = 0; i < m; i++) {
    koll[a[i]]++;
  }
  for (int k = 1; k <= n; k++) {
    for (int j = 0; j < n; j++) {
      for (int mask = 0; mask < kek + 1; mask++) {
        dp[j][mask] = koll[mask ^ (1 << j)] - dps[j][mask ^ (1 << j)];
      }
    }
    for (int mask = 0; mask < kek + 1; mask++) {
      koll[mask] = 0;
      for (int j = 0; j < n; j++) {
        koll[mask] += dp[j][mask];
        dps[j][mask] = dp[j][mask];
      }
      koll[mask] /= k;
      kol[mask] += min(k, n - k) * koll[mask];
    }
  }
  int anss = MOD;
  for (int i = 0; i < kek + 1; i++) {
    int ans = kol[i];
    anss = min(anss, ans);
  }
  cout << anss;
}
