#include <bits/stdc++.h>
using namespace std;
bool isLittleCircleinBigCircle(double x, double y, double r, double R,
                               double d) {
  return sqrt(x * x + y * y) + r <= R && sqrt(x * x + y * y) >= R - d + r;
}
int main() {
  int R, d, n, ans = 0;
  cin >> R >> d;
  cin >> n;
  int x, y, r;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> r;
    if (isLittleCircleinBigCircle(x, y, r, R, d) == 1) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}
