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