#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int r, d;
  cin >> r >> d;
  long long int n, c = 0;
  cin >> n;
  while (n--) {
    int x, y, r1;
    cin >> x >> y >> r1;
    double dist = sqrt(x * x + y * y);
    if (dist - r1 >= r - d && dist + r1 <= r) c++;
  }
  cout << c;
  return 0;
}
