#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  ;
  {
    int r, d, n, count = 0;
    cin >> r >> d >> n;
    int q = r - d;
    int x[n], y[n], r1[n];
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> r1[i];
    for (int i = 0; i < n; i++) {
      double dis = sqrt(x[i] * x[i] * 1.0 + y[i] * y[i] * 1.0);
      if (dis >= q && dis <= r) {
        long long mn = min(dis - q, r - dis);
        if (r1[i] <= mn) count++;
      }
    }
    cout << count << "\n";
  }
}
