#include <bits/stdc++.h>
int main() {
  float R, d, n;
  scanf("%f%f%f", &R, &d, &n);
  float x, y, r;
  int i;
  int count = 0;
  for (i = 0; i < n; ++i) {
    scanf("%f%f%f", &x, &y, &r);
    float dist = (x * x) + (y * y);
    dist = pow(dist, 1.0 / 2.0);
    if ((dist - r) >= (R - d) && (dist + r) <= R) count++;
  }
  printf("%d\n", count);
  return 0;
}
