#include <bits/stdc++.h>
using namespace std;
const int maxn = int(1e5) + 100;
int n, m;
int ans;
int cnt[30][maxn];
int col[maxn];
int f[30][1 << 20];
int getnum() {
  char ch;
  while ((ch = getchar()) != '0' && ch != '1')
    ;
  return (ch - '0');
}
void init() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) cnt[i][j] = getnum();
  for (int j = 1; j <= m; ++j)
    for (int i = 1; i <= n; ++i) col[j] |= cnt[i][j] << (i - 1);
}
void solve() {
  for (int i = 1; i <= m; ++i) f[0][col[i]]++;
  for (int i = 0; i < 1 << n; ++i)
    for (int j = 0; j < n; ++j) f[1][i] += f[0][i ^ (1 << j)];
  for (int i = 2; i <= n; ++i)
    for (int j = 0; j < 1 << n; ++j) {
      for (int k = 0; k < n; ++k) f[i][j] += f[i - 1][j ^ (1 << k)];
      f[i][j] = (f[i][j] + (i - 2 - n) * f[i - 2][j]) / i;
    }
  ans = n * m;
  for (int i = 0; i < 1 << n; ++i) {
    int s = 0;
    for (int j = 0; j <= n; ++j) s += f[j][i] * min(j, n - j);
    ans = min(ans, s);
  }
}
int main() {
  init();
  solve();
  printf("%d\n", ans);
  return 0;
}
