#include <bits/stdc++.h>
using namespace std;
int main() {
  int d, r;
  cin >> r >> d;
  int n;
  cin >> n;
  long long cpt = 0;
  for (int i = 0; i < n; i++) {
    int x, y, ra;
    cin >> x >> y >> ra;
    double distance = sqrt(x * x + y * y);
    if (distance < r - d || distance > r) continue;
    if (distance - ra >= (r - d) && distance + ra <= r) cpt++;
  }
  cout << cpt << endl;
}
