#include <bits/stdc++.h>
int i, j, n, m, k, l, p, ans;
double dis, r, d;
int main() {
  scanf("%lf%lf", &r, &d);
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    dis = (double)sqrt(x * x + y * y);
    if (dis + z <= r && dis - z >= r - d) ans++;
  }
  printf("%d", ans);
}
