#include <bits/stdc++.h>
using namespace std;
int main() {
  double r, d, x, y, a;
  int n, c = 0;
  scanf("%lf%lf%d", &r, &d, &n);
  while (n--) {
    scanf("%lf%lf%lf", &x, &y, &a);
    if ((sqrt(x * x + y * y) >= r - d + a) && (sqrt(x * x + y * y) + a <= r))
      c++;
  }
  printf("%d", c);
  return 0;
}
