#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, d;
  int n, x, y, rr;
  scanf("%d%d", &r, &d);
  scanf("%d", &n);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &x, &y, &rr);
    if (x * x + y * y <= (r - rr) * (r - rr) &&
        x * x + y * y >= (r - d + rr) * (r - d + rr)) {
      ans++;
    }
  }
  printf("%d\n", ans);
}
