#include <bits/stdc++.h>
int main() {
  int r, d, n, x, y, rad, sum = 0;
  int without_crust;
  double dcenter;
  scanf("%d %d %d", &r, &d, &n);
  without_crust = r - d;
  while (n--) {
    scanf("%d %d %d", &x, &y, &rad);
    x = abs(x), y = abs(y);
    dcenter = sqrt(x * x + y * y);
    if (dcenter + rad <= r && dcenter - rad >= without_crust) sum++;
  }
  printf("%d", sum);
  return 0;
}
