#include <bits/stdc++.h>
using namespace std;
double dis(long long int x, long long int y) { return sqrt(y * y + x * x); }
int main() {
  ios::sync_with_stdio(0);
  long long int r, d;
  cin >> r >> d;
  long long int n;
  cin >> n;
  long long int count = 0;
  while (n--) {
    double x, y, rr;
    cin >> x >> y >> rr;
    double dd = dis(x, y);
    if (dd + rr <= r && dd - rr >= r - d) count++;
  }
  cout << count << endl;
  return 0;
}
