#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
int x, y, r;
int main() {
  int R, d;
  scanf("%d%d", &R, &d);
  d = R - d;
  int n;
  scanf("%d", &n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &x, &y, &r);
    if (hypot(x, y) - r + eps >= d && hypot(x, y) + r <= R + eps) ans++;
  }
  printf("%d", ans);
}
