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