#include <bits/stdc++.h>   using namespace std;   int read() {     char c = getchar();     int d = 0, f = 1;     for (; c <  0  || c >  9 ; c = getchar())       if (c ==  - ) f = -1;     for (; c >=  0  && c <=  9 ; d = d * 10 + c - 48, c = getchar())       ;     return d * f;   }   int r, d, n;   const int N = 100001;   struct xint {     int x, y, r;   } a[N];   int main() {     r = read(), d = read(), n = read();     int ans = 0;     for (int i = 1; i <= n; ++i) {       a[i].x = read(), a[i].y = read(), a[i].r = read();       int dis = a[i].x * a[i].x + a[i].y * a[i].y;       if (dis >= (r - d + a[i].r) * (r - d + a[i].r) && r >= a[i].r &&           dis <= (r - a[i].r) * (r - a[i].r))         ans++;     }     cout << ans << endl;   }   