#include <bits/stdc++.h>
using namespace std;
const int V = 1<<20;
const int N = 22;
const int M = 100005;
int n,a[M];
long long dp[V],cnt[V];
char s[N][M];
int calc(int x) {
int ans = 0;
while (x) {
ans+=(x&1);
x>>=1;
}
return ans;
}
void FWT(long long *src,int len) {
for (int sz = 2;sz <= len; sz<<=1) {
int step = sz>>1;
for (int i = 0;i < len;i+=sz) {
for (int j = i;j < i+step;j++) {
long long a = src[j],b = src[j+step];
src[j] = a+b;
src[j+step] = a-b;
}
}
}
}
void IFWT(long long *src,int len) {
for (int sz = 2;sz <= len;sz <<= 1) {
int step = sz >> 1;
for (int i = 0;i<len;i+=sz) {
for (int j = i;j < i+step;j++) {
long long a = src[j],b = src[j+step];
src[j] = (a+b)>>1;
src[j+step] = (a-b)>>1;
}
}
}
}
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for (int i = 0;i<n;i++)
scanf("%s",s[i]+1);
for (int i = 1;i<= m;i++) {
int tmp = 0;
for (int j = 0;j < n;j++)
tmp |= ((s[j][i]-'0')<<j);
cnt[tmp]++;
}
int len = 1<<n;
for (int i = 0;i<len;i++)
{
int tmp = calc(i);
dp[i] = min(tmp,n-tmp);
}
FWT(cnt,len);
FWT(dp,len);
for (int j = 0;j < len;j++)
dp[j] *= cnt[j];
IFWT(dp,len);
long long ans = n*m+1;
for (int j = 0;j < len;j++)
ans = min(ans,dp[j]);
printf("%lld\n",ans);
return 0;
}