#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  double r, d, b, e, c;
  while (scanf("%lf%lf%d", &r, &d, &n) != EOF) {
    int x[n + 5], y[n + 5], z[n + 5], ans = 0;
    e = r - d;
    for (i = 0; i < n; i++) {
      scanf("%d%d%d", &x[i], &y[i], &z[i]);
      b = sqrt((x[i] * x[i] * 1.0) + (y[i] * y[i] * 1.0)) + z[i];
      c = sqrt((x[i] * x[i] * 1.0) + (y[i] * y[i] * 1.0)) - z[i];
      if ((b - r) <= 0 && (c - e) >= 0) ans++;
    }
    printf("%d\n", ans);
  }
  return 0;
}
