#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, cnt, j, t, x[100005], y[100005], r, r1, d;
  double dis;
  while (cin >> r >> d >> n) {
    cnt = 0;
    m = r - d;
    for (i = 1; i <= n; i++) {
      cin >> x[i] >> y[i] >> r1;
      dis = sqrt(x[i] * x[i] + y[i] * y[i]);
      if (dis - r1 >= r - d && dis + r1 <= r) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}
