#include <bits/stdc++.h>
using namespace std;
std::vector<long long> v;
long long x = 0, y = 0;
int main() {
  float r, d;
  long long ans = 0;
  cin >> r >> d;
  long long n;
  cin >> n;
  while (n--) {
    float x, y, k;
    cin >> x >> y >> k;
    if (k * 2 <= d) {
      float l = sqrt((x * x) + (y * y));
      if (l <= r && l >= (r - d)) {
        if (l + k <= r && l - k >= r - d) {
          ans++;
        }
      }
    }
  }
  cout << ans << "\n";
}
