#include<bits/stdc++.h> short k,n,ans; char w[1000][16]; int main(){ scanf("%hd %hd",&k,&n); for(short i=0;i<k;i++) for(short j=0;j<n;j++) scanf("%hd",&w[i][j]); for(short i=0;i<k;i++){ for(short j=0;j<n;j++){ if(w[i][j]=='2') break; if(j==k-1) ans++; } } printf("%hd",ans); return 0; }