#include <bits/stdc++.h>
using namespace std;
long long distance(long long x1, long long y1, long long x2, long long y2) {
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long r, d, n, cnt = 0, x, y, ri, RSmall, RBig;
  cin >> r >> d;
  cin >> n;
  RSmall = r - d;
  RBig = r;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> ri;
    if (distance(x, y, 0, 0) <= abs(ri - RBig) * abs(ri - RBig)) {
      if (distance(x, y, 0, 0) >= (ri + RSmall) * (ri + RSmall)) {
        ++cnt;
      }
    }
  }
  cout << cnt << "\n";
  return 0;
}
