#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, d;
  cin >> r >> d;
  int n;
  cin >> n;
  int ar[n][3], i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < 3; j++) cin >> ar[i][j];
  }
  int count = 0;
  double dt = 0;
  for (i = 0; i < n; i++) {
    dt = sqrt(pow(ar[i][0], 2) + pow(ar[i][1], 2));
    if (dt + ar[i][2] <= r && dt - (r - d) >= ar[i][2]) {
      count++;
    }
  }
  cout << count << endl;
}
