#include <bits/stdc++.h>
using namespace std;
bool contains(complex<long double> p1, long long r1, complex<long double> p2,
              long long r2) {
  long double dist = abs(p2 - p1);
  if (r1 >= r2 + dist) {
    return true;
  } else {
    return false;
  }
}
long double eps = 1e-9;
bool containsOut(complex<long double> p1, long long r1, complex<long double> p2,
                 long long r2) {
  long double dist = abs(p2 - p1);
  if (dist + eps >= r2 + r1) {
    return false;
  } else {
    return true;
  }
}
int solve(long long x, long long y, long long r, long long d1, long long r1) {
  int out = 0;
  complex<long double> start(0, 0);
  complex<long double> p1(x, y);
  bool flagR = false, flagD = false;
  if (d1 == 0) {
    long double dist = abs(p1);
    if (r1 == (r + dist) && 2 * r <= d1) {
      out = 1;
    }
  } else {
    flagR = contains(start, r1, p1, r);
    flagD = containsOut(start, r1 - d1, p1, r);
    if (flagR == true && flagD == false) {
      out = 1;
    }
  }
  return out;
}
int main() {
  int r, d, n;
  cin >> r >> d;
  cin >> n;
  int x1, y1, r1;
  int out = 0;
  for (int i = 0; i < n; ++i) {
    cin >> x1 >> y1 >> r1;
    out += solve(x1, y1, r1, d, r);
  }
  cout << out << endl;
  return 0;
}
