#include <bits/stdc++.h>
using namespace std;
int main() {
  double d, r;
  int n;
  scanf("%lf%lf", &d, &r);
  scanf("%d", &n);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    double x, y, rr;
    scanf("%lf%lf%lf", &x, &y, &rr);
    double dd = sqrt(x * x + y * y);
    if (dd - rr >= (d - r) && dd + rr <= d) cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}
