#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, d;
  cin >> r >> d;
  int n;
  cin >> n;
  int p = r - d;
  int count = 0;
  for (int i = 0; i < n; i++) {
    int a, x, y;
    cin >> x >> y >> a;
    double m = sqrt((x * x) + (y * y));
    if (m + a <= r && m - a >= p) {
      count++;
    }
  }
  cout << count;
}
