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