#include <bits/stdc++.h>
using namespace std;
int main() {
  long long r, d;
  cin >> r >> d;
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    long long x, y, cr;
    cin >> x >> y >> cr;
    if (x * x + y * y <= (r - cr) * (r - cr) && 2 * cr <= d &&
        x * x + y * y >= (r - d + cr) * (r - d + cr))
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}
