#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, r, d, x, y, ri;
  cin >> r >> d;
  cin >> N;
  long long int count = 0;
  long long int k = r - d;
  for (int i = 0; i < N; i++) {
    cin >> x >> y >> ri;
    long long int p = x * x + y * y;
    long long int k1 = (k + ri) * (k + ri);
    long long int k2 = (r - ri) * (r - ri);
    if (p >= k1 && p <= k2) ++count;
  }
  cout << count << endl;
}
