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