#include <bits/stdc++.h>
const long long MOD = 1000000007;
const long long MOD2 = 1000000009;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  double r, d;
  cin >> r >> d;
  int n, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long double xi, yi, ri;
    cin >> xi >> yi >> ri;
    long double r1, r2;
    r1 = sqrtl(xi * xi + yi * yi) - (r - d);
    r2 = r - sqrtl(xi * xi + yi * yi);
    if (min(r1, r2) >= ri) ans++;
  }
  cout << ans << "\n";
  return 0;
}
