#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
template <class T, class U>
inline void Max(T &a, U b) {
  if (a < b) a = b;
}
template <class T, class U>
inline void Min(T &a, U b) {
  if (a > b) a = b;
}
inline void add(int &a, int b) {
  a += b;
  while (a >= 1000000007) a -= 1000000007;
}
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = ans * (long long)a % 1000000007;
    a = (long long)a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
char s[22][100010];
int dp[22][(1 << 20) + 5];
int main() {
  int T, ca = 0, i, j, k, n = 0, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  for (int i = 0; i < m; i++) {
    int first = 0;
    for (int j = 0; j < n; j++) first = first * 2 + (s[j][i] == '1');
    dp[0][first]++;
  }
  for (int k = 1; k < n + 1; k++) {
    for (int i = 0; i < 1 << n; i++) {
      int sum = 0;
      for (int p = 0; p < n; p++) sum += dp[k - 1][i ^ (1 << p)];
      if (k >= 2) sum += (k - 2 - n) * dp[k - 2][i];
      dp[k][i] = sum / k;
    }
  }
  int ans = 1000000007;
  for (int i = 0; i < 1 << n; i++) {
    int sum = 0;
    for (int k = 0; k < n + 1; k++) {
      sum += min(k, n - k) * dp[k][i];
    }
    Min(ans, sum);
  }
  printf("%d\n", ans);
  return 0;
}
