#include <bits/stdc++.h>
long long int power(int x, int y) {
  int i = 0;
  long long int result = 1;
  for (i = 0; i < y; i++) result = result * x;
  return result;
}
int main() {
  int r, d, r1;
  int n;
  int x, y;
  int i = 0;
  double dist = 0;
  int count = 0;
  double temp1, temp2;
  scanf("%d %d", &r, &d);
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &x, &y, &r1);
    dist = power(x, 2) + power(y, 2);
    dist = sqrt(dist);
    temp1 = dist + r1;
    temp2 = dist - r1;
    if (temp1 <= r && temp2 >= r - d) count++;
  }
  printf("%d", count);
  return 0;
}
