#include <bits/stdc++.h>
using namespace std;
int main() {
  long long r, d, n;
  cin >> r >> d;
  cin >> n;
  long long x, y, rad;
  long long p;
  p = r - d;
  double dis = 0;
  long long g, h, cnt = 0, j, k;
  for (long long i = 0; i < n; i++) {
    cin >> x >> y >> rad;
    dis = sqrt(x * x * 1.0 + y * y * 1.0);
    g = abs(r - rad);
    h = r + rad;
    k = r - d + rad;
    if (dis <= g && k <= dis) cnt++;
  }
  cout << cnt << endl;
}
