#include <bits/stdc++.h>
using namespace std;
struct Node {
  int l, r;
  pair<int, int> v;
  int mid() { return (l + r) >> 1; }
};
struct HNode {
  int m, p;
  long long x, y, r, d;
  bool operator<(const HNode &cur) const { return d < cur.d; }
};
Node tree[4 * 250005];
HNode hook[250005];
int n;
vector<int> has;
void push_up(int pos) {
  tree[pos].v = min(tree[pos << 1].v, tree[pos << 1 | 1].v);
}
void build(int pos, int l, int r) {
  tree[pos].l = l;
  tree[pos].r = r;
  if (l == r) {
    tree[pos].v = make_pair(hook[l].m, l);
    return;
  }
  int mid = tree[pos].mid();
  build(pos << 1, l, mid);
  build(pos << 1 | 1, mid + 1, r);
  push_up(pos);
}
void update(int pos, int idx, int mass) {
  if (tree[pos].l == tree[pos].r) {
    tree[pos].v.first = mass;
    return;
  }
  int mid = tree[pos].mid();
  if (idx <= mid)
    update(pos << 1, idx, mass);
  else
    update(pos << 1 | 1, idx, mass);
  push_up(pos);
}
pair<int, int> query(int pos, int l, int r) {
  if (l <= tree[pos].l && tree[pos].r <= r) return tree[pos].v;
  int mid = tree[pos].mid();
  pair<int, int> ret = make_pair(0x3fffffff, 0x3fffffff);
  if (l <= mid) ret = min(ret, query(pos << 1, l, r));
  if (r > mid) ret = min(ret, query(pos << 1 | 1, l, r));
  return ret;
}
int bifind(long long v) {
  int l = 1, r = n, mid;
  if (hook[r].d <= v) return r;
  if (hook[l].d > v) return -1;
  while (l + 1 < r) {
    mid = (l + r) >> 1;
    if (hook[mid].d <= v)
      l = mid;
    else
      r = mid;
  }
  return l;
}
int main() {
  int i, j, k;
  while (scanf("%I64d%I64d%d%I64d%d", &hook[0].x, &hook[0].y, &hook[0].p,
               &hook[0].r, &n) != EOF) {
    for (i = 1; i <= n; i++)
      scanf("%I64d%I64d%d%d%I64d", &hook[i].x, &hook[i].y, &hook[i].m,
            &hook[i].p, &hook[i].r);
    for (i = 0; i <= n; i++) {
      hook[i].r *= hook[i].r;
      hook[i].d = (hook[0].x - hook[i].x) * (hook[0].x - hook[i].x) +
                  (hook[0].y - hook[i].y) * (hook[0].y - hook[i].y);
    }
    sort(hook + 1, hook + 1 + n);
    has.clear();
    has.push_back(0);
    build(1, 1, n);
    for (i = 0; i < has.size(); i++) {
      int rs = bifind(hook[has[i]].r);
      while (rs != -1) {
        pair<int, int> cur = query(1, 1, rs);
        if (cur.first <= hook[has[i]].p) {
          update(1, cur.second, 0x3fffffff);
          has.push_back(cur.second);
        } else
          break;
      }
    }
    printf("%d\n", has.size() - 1);
  }
  return 0;
}
