#include <bits/stdc++.h>
using namespace std;
vector<list<long long> > vc;
vector<long long> visited, segtree, height, pathv;
list<long long> path;
int main() {
  ifstream fin("Text.txt");
  int i, j, k;
  double a, b, c, e, n, m, r, d, q, d1, d2, d3, s1, s2, s3, c11, c21, c31, c12,
      c22, c32, ans = 0;
  string st1, st2;
  cin >> r >> d;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a >> b >> c;
    m = sqrt(a * a + b * b);
    if (m - c >= (r - d) && m + c <= r) ans++;
  }
  cout << ans << endl;
  return 0;
}
