#include<cstdio>
int x,y;
long long dist(int m,int n);
int main(){
freopen("c4.in","r",stdin);
freopen("c4.out","w",stdout);
int n,res=0;
long long r;
scanf("%d%d%lld%d",&x,&y,&r,&n);
r=r*r;
for(int i=0;i<=n;i++){
char c;
int m,n;
scanf("%c%d%d\n",&c,&m,&n);
if(c!='P')
continue;
if(dist(m,n)<=r)
res++;
}
printf("%d",res);
return 0;
}
long long dist(int m,int n){
return (m-x)*(m-x)+(n-y)*(n-y);
}