#include <iostream>
using namespace std;
int a[100][100],n,d,m,j,nr,ok,i;
int main()
{
cout<<"n=";cin>>n;
cout<<"m=";cin>>m;
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
{
cout<<"a["<<i<<"]["<<j<<"]=";cin>>a[i][j];
}
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
if(i%2==0)
{
ok=1;
if(a[i][j]==0||a[i][j]==1)ok=0;
for(d=2;d<=a[i][j]/2;d++)
if(a[i][j]%2==0)ok=0;
if(ok==1)
nr++;
}
cout<<nr;
return 0;
}