#include <bits/stdc++.h>
using namespace std;
struct sa {
  double x;
  double y;
  double sr;
} s[100005];
int main() {
  double r, d, n;
  cin >> r >> d >> n;
  double pr = r - d;
  for (int i = 0; i < n; i++) {
    scanf("%lf %lf %lf", &s[i].x, &s[i].y, &s[i].sr);
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    double dis = pow(s[i].x, 2) + pow(s[i].y, 2);
    dis = sqrtl(dis);
    cnt += (dis - pr >= s[i].sr) && (dis + s[i].sr <= r);
  }
  cout << cnt << endl;
  return 0;
}
