#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  std::ios::sync_with_stdio(false);
  double Rv, d;
  cin >> Rv >> d;
  double R = Rv - d;
  int n, counter = 0;
  cin >> n;
  for (int test = 0; test < n; test++) {
    double x, y, r;
    cin >> x >> y >> r;
    double dist = sqrt(x * x + y * y);
    if (dist >= R + r && dist <= R + d - r) {
      counter++;
    }
  }
  cout << counter;
  return 0;
}
