#include <bits/stdc++.h>
using namespace std;
int main() {
  int d, r, n, x, y, r1, c = 0;
  cin >> r >> d >> n;
  r = r - d;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> r1;
    double s = (double)sqrt(abs(x) * abs(x) + abs(y) * abs(y));
    if (s >= r + r1 && s + r1 <= r + d && r1 * 2 <= d) {
      c++;
    }
  }
  cout << c << endl;
  return 0;
}
