#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
int dp[21][1 << 21];
int arr[100009], val[22];
void solve(int x) {
  while (1) {
    int use;
    scanf("%d", &use);
    for (int i = 0; i < x; i++) {
      if ((use & (1 << i)))
        printf("1");
      else
        printf("0");
    }
    puts("");
  }
}
int main() {
  int n, m, res;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char ch;
      scanf(" %c", &ch);
      if (ch == '1') arr[j] |= (1 << (i - 1));
    }
  }
  int MASK = (1 << n), ans = 1000000007;
  for (int i = 1; i <= m; i++) dp[0][arr[i]]++;
  for (int i = 0; i < n; i++) {
    for (int dif = n; dif >= 1; dif--)
      for (int mask = 0; mask < MASK; mask++)
        dp[dif][mask] += dp[dif - 1][mask ^ (1 << i)];
    val[i] = min(i, n - i);
  }
  for (int i = 0; i < MASK; i++) {
    res = 0;
    for (int j = 0; j <= n; j++) res += dp[j][i] * val[j];
    umin(ans, res);
  }
  printf("%d\n", ans);
  return 0;
}
