#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int r1, d;
  cin >> r1 >> d;
  long long int n;
  cin >> n;
  long long int count = 0;
  int x[n], y[n], r[n], i;
  for (i = 0; i < n; i++) cin >> x[i] >> y[i] >> r[i];
  double dfo;
  for (i = 0; i < n; i++) {
    dfo = sqrt(x[i] * x[i] + y[i] * y[i]);
    if (dfo >= double(r1 - d + r[i])) {
      if ((dfo + double(r[i])) <= double(r1)) count = count + 1;
    }
  }
  cout << count << endl;
  return 0;
}
