#include <bits/stdc++.h>
int main() {
  int r, d, n, i, r1, r2, sum = 0, x, y;
  double dis, dis1, dis2;
  scanf("%d %d", &r, &d);
  r1 = r;
  r2 = r - d;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d %d %d", &x, &y, &r);
    dis2 = sqrt(x * x + y * y) - r;
    dis1 = sqrt(x * x + y * y) + r;
    if (r1 >= dis1 && r2 <= dis2) sum++;
  }
  printf("%d\n", sum);
  return 0;
}
