#include <bits/stdc++.h>
using namespace std;
int main() {
  double r, d, x, y, rd;
  int n;
  scanf("%lf%lf", &r, &d);
  scanf("%d", &n);
  int count = 0;
  while (n--) {
    scanf("%lf%lf%lf", &x, &y, &rd);
    double ans = sqrt(x * x + y * y) + rd;
    double dis = ans - 2 * rd;
    if (ans <= r && dis >= (r - d)) count++;
  }
  printf("%d\n", count);
  return 0;
}
