#include <iostream>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.in", "r", stdin);
#endif
int n,m;
cin>>n>>m;
char grid[n][m];
for(int i = 0 ; i<n ; i++){
for(int j = 0 ; j<m ;j++){
cin>>grid[i][j];
}
}
int ans = 0;
int ons[n]{};
for(int j = 0 ; j<m ; j++){
int on = 0, idx;
for(int i = 0 ; i<n ; i++){
if(grid[i][j] == '1')on++, idx = i;
}
if(on == 1)
ons[idx]++;
}
for(int i = 0 ; i<n ; i++){
if(ons[i])
ans++;
}
cout<<ans;
}
// 1 1 2 3 5 8 13 21
Copy