#include <bits/stdc++.h>
using namespace std;
double ub, lb, R, D;
int N;
int sgn(double a, double b) {
  if (fabs(a - b) <= 1e-7) return 0;
  if (a > b) return 1;
  return -1;
}
int main() {
  cin >> R >> D >> N;
  lb = (R - D), ub = R;
  int cnt = 0;
  for (int i = 0; i < (N); ++i) {
    double x, y, r;
    scanf("%lf %lf %lf", &x, &y, &r);
    double dis = sqrt(x * x + y * y);
    if (sgn(dis - r, lb) != -1 && sgn(dis + r, ub) != 1) cnt++;
  }
  printf("%d\n", cnt);
}
