#include <bits/stdc++.h>
using namespace std;
long long int n, m, s = 0, k = 0;
void solve(int r) {
  int d, x, y, j, k, n, q = 0, i;
  scanf("%d%d", &d, &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d%d", &x, &y, &j);
    if (x * x + y * y < (r - d + j) * (r - d + j)) {
    } else if (x * x + y * y > (r - j) * (r - j)) {
    } else {
      q++;
    }
  }
  printf("%d\n", q);
}
int main() {
#pragma warning(disable : 4996);
  int a, b, n;
  while (scanf("%d", &n) != EOF) solve(n);
  return 0;
}
