#include <bits/stdc++.h>
using namespace std;
int r, d, n, x, y, rd, resp;
double dt;
int main() {
  scanf("%d %d %d", &r, &d, &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &x, &y, &rd);
    dt = (double)sqrt((double)(x * x) + (double)(y * y));
    if ((double)dt - rd >= (double)r - d && (double)r - dt >= (double)rd)
      resp++;
  }
  printf("%d\n", resp);
  return 0;
}
