#include <bits/stdc++.h>
using namespace std;
template <class T>
void test(T a) {
  cout << a << endl;
}
template <class T, class T2>
void test(T a, T2 b) {
  cout << a << " " << b << endl;
}
template <class T, class T2, class T3>
void test(T a, T2 b, T3 c) {
  cout << a << " " << b << " " << c << endl;
}
const int N = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
long long R, D;
struct node {
  long long r, x, y;
};
int check(node a) {
  long long mid = (a.x * a.x + a.y * a.y);
  long long l = 1ll * (D + a.r) * (D + a.r);
  long long r = 1ll * (R + a.r) * (R + a.r);
  long long l1 = 1ll * (D - a.r) * (D - a.r);
  long long r1 = 1ll * (R - a.r) * (R - a.r);
  double chang = (double)sqrt(a.x * a.x + a.y * a.y) + a.r;
  if (l <= mid && mid <= r) {
    if (l1 <= mid && mid <= r1) {
      return 1;
    }
  }
  return 0;
}
void work() {
  cin >> R >> D;
  D = R - D;
  int n;
  cin >> n;
  node t;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> t.x >> t.y >> t.r;
    if (check(t)) {
      ans++;
    }
  }
  cout << ans << endl;
}
int main() {
  bool LOCAL = 0;
  ios::sync_with_stdio(false);
  cin.tie(0);
  bool mulcase = 0;
  if (mulcase) {
    int t;
    cin >> t;
    while (t--) {
      work();
    }
  } else
    work();
}
