#include <bits/stdc++.h>
using namespace std;
int d, r, n, x, y, w;
double eps = 1e-6;
double dis() {
  double ta = x * x + y * y;
  ta = sqrt(ta);
  return ta;
}
bool check() {
  double ta = dis();
  int flag = 0;
  if ((ta - w >= r - d) && (ta + w <= r)) return 1;
  return 0;
}
int main() {
  cin >> r >> d;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> w;
    if (check()) ans++;
  }
  cout << ans << endl;
  return 0;
}
