#include <bits/stdc++.h>
using namespace std;
queue<int> gripQ;
int shipX;
int shipY;
class gripper;
class node;
class comp;
class gripper {
 public:
  int mass, power, radius;
  double dist;
  bool added;
  gripper(long long x, long long y, int intoMass, int intoPower,
          int intoRadius) {
    dist =
        sqrt((double)((x - shipX) * (x - shipX) + (y - shipY) * (y - shipY)));
    mass = intoMass;
    power = intoPower;
    radius = intoRadius;
    added = false;
  }
  gripper() {}
  bool operator<(gripper comp) const { return dist < comp.dist; }
} grippers[250001];
class comp {
 public:
  int num;
  bool operator<(comp com) const {
    return grippers[num].mass < grippers[com.num].mass;
  }
};
class node {
 public:
  comp* q;
  int pointer;
  int length;
  node* left;
  node* right;
  double lowerDist, upperDist;
  int lowerBound, upperBound;
  node() {}
  node(int intoLower, int intoUpper) {
    lowerBound = intoLower;
    upperBound = intoUpper;
    lowerDist = grippers[lowerBound].dist;
    upperDist = grippers[upperBound].dist;
    length = upperBound - lowerBound + 1;
    pointer = 0;
    q = new comp[length];
    for (int i = lowerBound; i <= upperBound; i++) q[i - lowerBound].num = i;
    sort(q, q + length);
    if (lowerBound != upperBound) {
      left = new node(lowerBound, (lowerBound + upperBound) / 2);
      right = new node((lowerBound + upperBound) / 2 + 1, upperBound);
    } else {
      left = NULL;
      right = NULL;
    }
  }
  void addGrippers(double upper, int upperMass) {
    if (lowerDist > upper) return;
    if (upper >= upperDist) {
      while (pointer < length && grippers[q[pointer].num].mass <= upperMass) {
        int next = q[pointer].num;
        pointer++;
        if (!grippers[next].added) {
          gripQ.push(next);
          grippers[next].added = true;
        }
      }
      return;
    }
    if (left != NULL) left->addGrippers(upper, upperMass);
    if (right != NULL) right->addGrippers(upper, upperMass);
  }
};
int main() {
  int power, radius, gripNum, i, nextX, nextY, nextMass, nextPower, nextRadius;
  scanf("%d %d %d %d %d", &shipX, &shipY, &power, &radius, &gripNum);
  for (i = 0; i < gripNum; i++) {
    scanf("%d %d %d %d %d", &nextX, &nextY, &nextMass, &nextPower, &nextRadius);
    grippers[i] = *new gripper(nextX, nextY, nextMass, nextPower, nextRadius);
  }
  sort(grippers, grippers + gripNum);
  node* root = new node(0, gripNum - 1);
  int fetchNum = 0;
  root->addGrippers(radius, power);
  while (!gripQ.empty()) {
    gripper* nextG = &grippers[gripQ.front()];
    gripQ.pop();
    fetchNum++;
    root->addGrippers(nextG->radius, nextG->power);
  }
  printf("%d\n", fetchNum);
  return 0;
}
