#include <bits/stdc++.h>
using namespace std;
int main() {
  int R = 0;
  int d = 0;
  int n = 0;
  cin >> R;
  cin >> d;
  cin >> n;
  int x;
  int y;
  int r;
  int counter = 0;
  double low = 0;
  double high = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    cin >> y;
    cin >> r;
    if (((sqrt(x * x + y * y) - r) >= (R - d)) &&
        ((sqrt(x * x + y * y) + r) <= R))
      counter++;
  }
  cout << counter;
  return 0;
}
