#include <bits/stdc++.h>
using namespace std;
int R, d, n;
int x, y, r;
double dist(int x, int y) { return sqrt(x * x + y * y); }
void solve() {
  int cnt = 0;
  while (n--) {
    scanf("%d%d%d", &x, &y, &r);
    if (dist(x, y) - r >= R - d && dist(x, y) + r <= R) cnt++;
  }
  printf("%d\n", cnt);
}
int main() {
  while (~scanf("%d%d%d", &R, &d, &n)) {
    solve();
  }
  return 0;
}
