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