#include <iostream>
using namespace std;
int main()
{int n,i,vec[250],s,nr=0;
cin>>n;
for (i=1;i<=n;i++)
cin>>vec[i];
for (i=1;i<=n;i++)
{s=0;
while (vec[i]>0)
{s=s+vec[i]%10;
vec[i]=vec[i]/10;}
if (s%3==0)
nr=nr+1;}
cout<<"Numere care respecta regula: "<<nr<<endl;
return 0;
}