#include <bits/stdc++.h>
using namespace std;
int main() {
  long double r, d;
  scanf(" %Lf %Lf", &r, &d);
  int n;
  scanf(" %d", &n);
  int res = 0;
  for (int i = 0; i < n; i++) {
    long double x, y, s;
    scanf(" %Lf %Lf %Lf", &x, &y, &s);
    long double dis = sqrt(x * x + y * y);
    if ((dis - s) >= (r - d) && (dis + s) <= r) {
      res++;
    }
  }
  printf("%d\n", res);
  return 0;
}
