#include <bits/stdc++.h>
int r, d, n, x, y, rr, ans;
__inline double dist(double xx, double yy) { return sqrt(xx * xx + yy * yy); }
int main() {
  scanf("%d%d%d", &r, &d, &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &x, &y, &rr);
    if (dist(x, y) - rr >= r - d && dist(x, y) + rr <= r) ans++;
  }
  printf("%d", ans);
}
