#include <bits/stdc++.h>
using namespace std;
int dis(int x, int y) { return (x * x + y * y); }
int main() {
  int d, n, i, x, y, r, cnt = 0, R1, R2;
  cin >> r >> d;
  R1 = r;
  R2 = r - d;
  cin >> n;
  while (n--) {
    cin >> x >> y >> r;
    d = dis(x, y);
    if (d <= ((R1 - r) * (R1 - r)) && d >= ((R2 + r) * (R2 + r))) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
