#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int maxn = 1e5 + 10;
double R, d;
int n, ans;
int main() {
  scanf("%lf%lf%d", &R, &d, &n);
  R -= d;
  for (int i = 0; i < n; i++) {
    double x, y, r;
    scanf("%lf%lf%lf", &x, &y, &r);
    double dist = sqrt(x * x + y * y);
    if ((dist >= r + R || fabs(dist - (r + R)) <= eps) &&
        ((dist + r <= R + d) || (fabs(dist + r - (R + d)) <= eps)))
      ans++;
  }
  printf("%d\n", ans);
  return 0;
}
