#include <bits/stdc++.h>
using namespace std;
double dist(long long x, long long y) { return sqrt(x * x + y * y); }
int main() {
  long long R, d, x, y, r, t, Count = 0;
  cin >> R >> d;
  cin >> t;
  while (t--) {
    cin >> x >> y >> r;
    double m = dist(x, y);
    if (m - r >= (R - d) && m + r <= R) Count++;
  }
  cout << Count << endl;
  return 0;
}
