#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int r, d, n;
  cin >> r >> d >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int x, y, ri;
    cin >> x >> y >> ri;
    double dist = sqrt((x * x) + (y * y));
    if (dist + ri <= r && dist - ri >= r - d) ans++;
  }
  cout << ans;
  return 0;
}
