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