#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 main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int r, d, n, xi, yi, ri, ans = 0;
  double dist;
  r = read();
  d = read();
  n = read();
  while (n--) {
    xi = read();
    yi = read();
    ri = read();
    dist = sqrt(xi * xi + yi * yi);
    if (dist + ri <= r && dist - ri >= (r - d)) ans++;
  }
  cout << ans;
}
