#include <bits/stdc++.h>
using namespace std;
vector<long long> localRes;
int main() {
  iostream::sync_with_stdio();
  cin.tie(0);
  int r, d;
  cin >> r >> d;
  int n;
  cin >> n;
  int cnt = 0;
  int ri, x, y;
  for (int i = 0; i < (int)(n); ++i) {
    cin >> x >> y >> ri;
    double dist = sqrt(x * x + y * y);
    if (dist - ri >= r - d && dist + ri <= r) {
      cnt++;
    }
  }
  cout << cnt;
}
