#include <bits/stdc++.h>
const long long inf = std::numeric_limits<long long>::max();
const long long mod = 1e9 + 7;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long double d, r;
  cin >> r >> d;
  long double n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    long double x, y, rr;
    cin >> x >> y >> rr;
    long double f = sqrt(x * x + y * y);
    if (f + rr <= r && f - rr >= r - d) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}
