#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
int cmp(double a, double b = 0.0) {
  if (fabs(a - b) < eps) return 0;
  if (a < b) return -1;
  return 1;
}
int main() {
  long long d, r, n, c = 0;
  cin >> r >> d >> n;
  d = r - d;
  for (int i = 0, __ = n; i < __; i++) {
    long long x, y, R;
    double D;
    cin >> x >> y >> R;
    D = sqrt(x * x + y * y);
    if (cmp(r, D + R) >= 0 && cmp(d, D - R) <= 0) {
      c++;
    }
  }
  cout << c << endl;
}
