#include <bits/stdc++.h>
using namespace std;
struct node {
  double x, y, r;
};
double dis(node a, node b) {
  double dx = a.x - b.x, dy = a.y - b.y;
  return sqrt(dx * dx + dy * dy);
}
double R, d;
node origin = {0, 0};
bool check(node a) {
  double distance = dis(a, origin);
  if (distance - a.r >= R - d && distance + a.r <= R) return true;
  return false;
}
int main() {
  scanf("%lf%lf", &R, &d);
  int k, ans = 0;
  scanf("%d", &k);
  while (k--) {
    node now;
    scanf("%lf%lf%lf", &now.x, &now.y, &now.r);
    if (check(now)) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
