#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, d;
  cin >> r >> d;
  int n;
  cin >> n;
  int i, j, r1[n], x[n], y[n];
  int ans = 0;
  for (i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> r1[i];
    float b = sqrt(x[i] * x[i] + y[i] * y[i]);
    if ((b - r1[i] >= r - d) && (b + r1[i] <= r)) ans++;
  }
  cout << ans << endl;
  return 0;
}
