#include <bits/stdc++.h>
using namespace std;
const int INF = 1061109567;
const long long LINF = 4557430888798830399ll;
const int MOD = 1000000007;
void test_case() {
  int R1, R2, d;
  scanf("%d%d", &R2, &d);
  R1 = R2 - d;
  int n;
  scanf("%d", &n);
  int cnt = 0;
  while (n--) {
    int x, y, r;
    scanf("%d%d%d", &x, &y, &r);
    int D = (x * x + y * y);
    long long Y = R2 * R2 - 2 * R2 * r + r * r;
    if (D > Y) continue;
    Y = R1 * R1 + 2 * R1 * r + r * r;
    if (D < Y) continue;
    ++cnt;
  }
  printf("%d\n", cnt);
}
int main() {
  int t = 1;
  for (int i = 1; i <= t; ++i) {
    test_case();
  }
}
