#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, d, n;
  cin >> r >> d >> n;
  int i;
  int sum = 0;
  for (i = 1; i <= n; i++) {
    int x, y, radius;
    cin >> x >> y >> radius;
    double distance = sqrt(x * x + y * y);
    if (distance >= (double)(r - d + radius) && distance <= (double)r - radius)
      sum++;
  }
  cout << sum;
}
