#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int inv = 499122177;
char mp[20][100005];
int bit = 0, len = 0;
void FWT(int *A, int flag) {
  for (int i = 0; i < bit; i++)
    for (int j = 0; j < len; j++)
      if ((j) & (1 << i)) {
        (A[(j)] += A[(j ^ (1 << i))]) %= mod;
        (A[(j ^ (1 << i))] = A[(j)] - 2 * A[(j ^ (1 << i))]) % mod;
        A[(j)] = 1ll * A[(j)] * flag % mod;
        A[(j ^ (1 << i))] = 1ll * A[(j ^ (1 << i))] * flag % mod;
      }
}
void FCP(int *A) {
  for (int i = 0; i < (len >> 1); i++) swap(A[i], A[i ^ (len - 1)]);
}
void FMD(int *A) {
  for (int i = 0; i < len; i++) A[i] = (A[i] % mod + mod) % mod;
}
void FML(int *A, int *B) {
  for (int i = 0; i < len; i++) A[i] = 1ll * A[i] * B[i] % mod;
}
int A[1 << 20];
int B[1 << 20];
int main() {
  int n, m;
  cin >> n >> m;
  bit = n;
  len = 1 << bit;
  for (int i = 0; i < n; i++) cin >> mp[i];
  for (int i = 0; i < m; i++) {
    int all = 0;
    for (int j = 0; j < n; j++) (all <<= 1) |= (mp[j][i] - '0');
    A[all]++;
  }
  for (int i = 0; i < len; i++) {
    B[i] = __builtin_popcount(i);
    B[i] = min(B[i], bit - B[i]);
  }
  FWT(A, 1);
  FWT(B, 1);
  FML(A, B);
  FWT(A, inv);
  FCP(A);
  FMD(A);
  int ans = mod;
  for (int i = 0; i < len; i++) ans = min(ans, A[i]);
  cout << ans;
  return 0;
}
