#include <bits/stdc++.h>
using namespace std;
int ri() {
  char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  int X = c - 48;
  while (c = getchar(), c >= '0' && c <= '9') X = X * 10 + c - 48;
  return X;
}
int main() {
  ios_base::sync_with_stdio(0);
  int r1, d, r2, x, y, n, ans = 0;
  cin >> r1 >> d >> n;
  r1 -= d;
  while (n--) {
    cin >> x >> y >> r2;
    if (sqrt(x * x + y * y) - r2 >= r1 and sqrt(x * x + y * y) + r2 <= r1 + d) {
      ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}
