#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000005;
const double eps = 1e-9;
double computeDistance(const std::pair<double, double>& point1,
                       const std::pair<double, double>& point2) {
  double x_diff = point1.first - point2.first;
  double y_diff = point1.second - point2.second;
  return std::sqrt(x_diff * x_diff + y_diff * y_diff);
}
bool isOnCrust(std::pair<double, double> pizza_origin, double pizza_radius,
               std::pair<double, double> sousage_origin, double sousage_radius,
               double crust_length) {
  double distance = computeDistance(pizza_origin, sousage_origin);
  return distance + sousage_radius - eps < pizza_radius + crust_length &&
         distance - sousage_radius + eps > pizza_radius;
}
int main() {
  ios_base::sync_with_stdio(0);
  double pizza_crust_radius, crust_length;
  const std::pair<double, double> pizza_origin = {0, 0};
  cin >> pizza_crust_radius >> crust_length;
  double pizza_radius = pizza_crust_radius - crust_length;
  int n;
  cin >> n;
  int sousages_on_crust = 0;
  for (int i = 0; i < n; ++i) {
    double x, y, radius;
    cin >> x >> y >> radius;
    sousages_on_crust +=
        isOnCrust(pizza_origin, pizza_radius, {x, y}, radius, crust_length);
  }
  cout << sousages_on_crust;
  return 0;
}
