#include <bits/stdc++.h>
using namespace std;
int main() {
  int d, r, n, cnt = 0;
  scanf("%d%d%d", &r, &d, &n);
  while (n--) {
    int x, y, ri;
    scanf("%d%d%d", &x, &y, &ri);
    double g = r - d;
    double u = sqrt(x * x + y * y);
    if (u + ri <= r) {
      if (u - ri >= g) cnt++;
    }
  }
  printf("%d", cnt);
  return 0;
}
