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