#include<bits/stdc++.h>
using namespace std;
int n,m,ans,x,y,row;
bool a[10000][10000],an[10000],b[10000];
int main()
{
cin>>n>>m;
for(int i=1;i<=m;i++)
for(int j=1;j<=n;j++)
cin>>a[i][j];
for(int i=1;i<=n;i++)
cin>>b[i];
row=0;
for(int k=1;k<=n;k++)
{
x=0,y=0;
row++;
if(row>m)
break;
for(int j=1;j<=n;j++)
{
if(a[row][j]==1)
x++;
if(a[row][j]==0)
y++;
// cout<<x<<" "<<y<<endl;
}
if(x>y)
an[k]==1;
if(x<y)
an[k]==0;
if(an[k]==b[k])
ans++;
// cout<<ans<<endl;
}
cout<<ans;
return 0;
}