#include <bits/stdc++.h>
using namespace std;
int main() {
  int d;
  long i, n, x, y, r1, r, coun;
  cin >> r >> d;
  cin >> n;
  coun = 0;
  for (i = 0; i < n; i++) {
    cin >> x >> y >> r1;
    if (x * x + y * y >= (r - d + r1) * (r - d + r1) &&
        x * x + y * y <= (r - r1) * (r - r1) && 2 * r1 <= d)
      coun++;
  }
  cout << coun << "\n";
  return 0;
}
