#include <bits/stdc++.h>
using namespace std;
double R, D;
int N;
double dist(double x, double y) { return sqrt(x * x + y * y); }
int main() {
  scanf("%lf %lf", &R, &D);
  int N;
  scanf("%d", &N);
  double x, y, r;
  int ans = 0;
  while (N--) {
    scanf("%lf %lf %lf", &x, &y, &r);
    double dis = dist(x, y);
    double mn = dis - r;
    double mx = dis + r;
    if (mn >= R - D && mx <= R) ans++;
  }
  printf("%d\n", ans);
}
