#include <bits/stdc++.h>
const int INF = 1 << 29;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  ;
  int r, d, n;
  std::cin >> r >> d >> n;
  int crustmax = r;
  int crustmin = r - d;
  int ans = 0;
  while (n--) {
    int x, y, ri;
    std::cin >> x >> y >> ri;
    if ((std::sqrt(x * x + y * y)) + ri <= r)
      if (std::sqrt(x * x + y * y) >= r - d + ri) ans++;
  }
  std::cout << ans;
  return 0;
}
