#include <iostream>
#include <iomanip>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <ctime>
#include <cassert>
#include <algorithm>
#include <cmath>
//#include <unordered_set>
//#include <unordered_map>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define for1(i, n) for (int i = 1; i < int(n); i++)
#define forft(i, from, to) for (int i = int(from); i < int(to); i++)
#define forr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define ms(a, v) memset(a, v, sizeof(a))
#define correct(x, y, n, m) (x >= 0 && x < n && y >= 0 && y < m)
using namespace std;
template<typename T> T sqr(const T &x) {
return x * x;
}
typedef long long ll;
typedef long long li;
typedef pair<int, int> pt;
typedef long double ld;
typedef pair<ld, ld> pd;
const int INF = int(1e9);
const ll INF_LL = ll(4e18);
const ll INF64 = ll(4e18);
const ll LINF = ll(4e18);
const ld EPS = 1e-9;
const ld PI = 3.14159265358979323846264338;
int r, d;
int n;
bool read() {
scanf("%d%d%d", &r, &d, &n);
return true;
}
void solve() {
int ans = 0;
forn(i, n) {
int x, y, cr;
scanf("%d%d%d", &x, &y, &cr);
if (sqr(li(x)) + sqr(li(y)) <= sqr(li(r - cr)) && 2 * cr <= d && sqr(li(x)) + sqr(li(y)) >= sqr(li(r - d + cr))) {
++ans;
}
}
printf("%d\n", ans);
}
int main() {
srand((int) time(NULL));
cout << setprecision(10) << fixed;
read();
solve();
cerr << clock() << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aW9tYW5pcD4KI2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPHF1ZXVlPgojaW5jbHVkZSA8c3RhY2s+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDxj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