#include <bits/stdc++.h>
using namespace std;
bool inD(int x, int y, int r1, int r, int d, bool v) {
  double dist = sqrt(double(x) * x + y * y);
  if (v) {
    printf("dist = %lf\n", dist);
    printf("dist + r1 = %lf\n", dist + r1);
    printf("dist - r1 = %lf\n", dist - r1);
    printf("r = %lf\n", double(r));
    printf("r-d = %lf\n", double(r) - d);
  }
  bool inR = dist + r1 <= r;
  bool outOfRmD = dist - r1 >= r - d;
  return inR && outOfRmD;
}
int main() {
  int r, d, n;
  scanf("%d%d%d", &r, &d, &n);
  int res = 0;
  for (int i = 0; i < n; ++i) {
    int x, y, r1;
    scanf("%d%d%d", &x, &y, &r1);
    res += inD(x, y, r1, r, d, false);
  }
  printf("%d\n", res);
  return 0;
}
