#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
const double eps = 1e-9;
double juli(double x, double y) { return sqrt(y * y + x * x); }
int main() {
  double r, d, x, y, R;
  int n;
  int ans = 0;
  cin >> r >> d >> n;
  double j1, j2;
  for (int i = 0; i < n; i++) {
    scanf("%lf %lf %lf", &x, &y, &R);
    j1 = juli(x, y) - R;
    j2 = juli(x, y) + R;
    if (j1 >= (r - d) && j2 <= r) ans++;
  }
  cout << ans << endl;
}
