#include <bits/stdc++.h>
const long double eps = 0.000000001;
int main() {
  short r, d;
  int n, i, xi, yi, ri, c = 0;
  scanf("%hd%hd%d", &r, &d, &n);
  for (i = 0; i < n; ++i) {
    scanf("%d%d%d", &xi, &yi, &ri);
    if ((long double)sqrt(xi * xi + yi * yi) + (long double)ri <=
            (long double)r + eps &&
        (long double)sqrt(xi * xi + yi * yi) - (long double)ri >=
            (long double)r - d - eps) {
      ++c;
    }
  }
  printf("%d", c);
  return 0;
}
