#include <bits/stdc++.h>
using namespace std;
int r, d, n, ans;
double GetDistance(pair<int, int> const &p1, pair<int, int> const &p2) {
  return sqrt((p2.first - p1.first) * (p2.first - p1.first) +
              (p2.second - p1.second) * (p2.second - p1.second));
}
int main() {
  scanf("%d%d", &r, &d);
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    pair<int, int> tmp;
    int radius;
    scanf("%d%d%d", &tmp.first, &tmp.second, &radius);
    double dt = GetDistance(tmp, pair<int, int>(0, 0));
    if (dt + radius <= r && dt - (r - d) >= radius) ++ans;
  }
  printf("%d\n", ans);
  return 0;
}
