#include <bits/stdc++.h>
int xi[111111];
int yi[111111];
int ri[111111];
int main() {
  int R, d;
  int n;
  scanf("%d %d", &R, &d);
  int r = R - d;
  scanf("%d", &n);
  int c = 0;
  for (int i = 0; i < n; i++) {
    int flag = 1;
    scanf("%d %d %d", &xi[i], &yi[i], &ri[i]);
    double D =
        sqrt((double)xi[i] * (double)xi[i] + (double)yi[i] * (double)yi[i]);
    if (!(D <= fabs((double)R - (double)ri[i]))) flag = 0;
    if (!(D >= fabs((double)r + (double)ri[i]))) flag = 0;
    if (flag == 1) c++;
  }
  printf("%d\n", c);
  return 0;
}
