#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long r, d, n;
  cin >> r >> d >> n;
  long long res = 0;
  for (long long i = 0; i < n; i++) {
    long long x, y, ri;
    cin >> x >> y >> ri;
    long long dist = x * x + y * y;
    long long low = r - d + ri;
    long long high = r - ri;
    low *= low;
    high *= high;
    if (dist >= low && dist <= high) res++;
  }
  cout << res << '\n';
}
