#include <bits/stdc++.h>
using namespace std;
int main() {
  float r, d;
  cin >> r >> d;
  float y = r, x = r - d;
  int n;
  cin >> n;
  int t = 0;
  while (n--) {
    int a, b, rr;
    cin >> a >> b >> rr;
    float dist = sqrt(a * a + b * b);
    if (dist - rr >= x && dist + rr <= y) {
      t++;
    }
  }
  cout << t;
}
