#include <iostream>
using namespace std;
bool prim(unsignedint x)
{
if(x == 1)
{
return true;
}
for(int i = 2; i <= x; i++)
{
if(x % i == 0)
return true;
return false;
}
}
int main()
{
unsigned int n, m, c = 0;
cin >> n >> m;
unsigned int a[100][100];
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
cin >> a[i][j];
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
if(i % 2 == 0 && prim(a[i][j]) == true)
c++;
cout << c;
return 0;
}