#include <bits/stdc++.h>
using namespace std;
bool isOnCrust(int rpi, int anchcrust, int x, int y, int r) {
  if (sqrt(pow(x, 2) + pow(y, 2)) <= (rpi - r) &&
      sqrt(pow(x, 2) + pow(y, 2)) >= r + (rpi - anchcrust))
    return true;
  return false;
}
int main() {
  int rpi, anchcrust, x, y, r, sal, cont = 0, i = 1;
  cin >> rpi;
  cin >> anchcrust;
  cin >> sal;
  while (i <= sal) {
    cin >> x;
    cin >> y;
    cin >> r;
    if (isOnCrust(rpi, anchcrust, x, y, r)) cont++;
    i++;
  }
  cout << cont;
  return 0;
}
