#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const double PI = 4 * atan(1);
const double eps = 1e-4;
long double rad, d;
int n;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> rad >> d >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    long double x, y, r;
    cin >> x >> y >> r;
    long double dist = sqrt(x * x + y * y);
    if ((dist + r <= rad) && (dist - r >= rad - d)) {
      cnt++;
    }
  }
  cout << cnt;
}
