#include <bits/stdc++.h>
using namespace std;
const int maxn = 262145;
struct node {
  int x, y, m, p, r;
  double d;
} a[maxn];
multiset<pair<int, int> > tree[maxn << 1];
int q[maxn], size[maxn << 1];
bool vis[maxn];
int n, ans = 0;
void init() {
  scanf("%d%d%d%d%d", &a[0].x, &a[0].y, &a[0].p, &a[0].r, &n);
  for (int i = 1; i <= n; i++)
    scanf("%d%d%d%d%d", &a[i].x, &a[i].y, &a[i].m, &a[i].p, &a[i].r);
}
double cal(node a, node b) {
  return sqrt(double(a.x - b.x) * (a.x - b.x) +
              double(a.y - b.y) * (a.y - b.y));
}
bool cmp(const node &x, const node &y) { return x.d < y.d; }
void build(int v, int s, int t) {
  for (int i = s; i <= t; i++) tree[v].insert(make_pair(a[i].m, i));
  size[v] = t - s + 1;
  if (s == t) return;
  build(v * 2, s, (s + t) / 2);
  build(v * 2 + 1, (s + t) / 2 + 1, t);
}
void update(int v, int s, int t, int p, int r) {
  if (size[v] <= 0) return;
  if (a[t].d <= r) {
    for (multiset<pair<int, int> >::iterator it = tree[v].begin();
         it != tree[v].end(); it = tree[v].begin()) {
      if ((*it).first > p) break;
      if (!vis[(*it).second]) {
        q[++ans] = (*it).second;
        vis[(*it).second] = true;
      }
      tree[v].erase(it);
      size[v]--;
    }
    return;
  }
  if (s == t) return;
  if (a[s].d <= r) update(v * 2, s, (s + t) / 2, p, r);
  if (a[(s + t) / 2 + 1].d <= r) update(v * 2 + 1, (s + t) / 2 + 1, t, p, r);
}
void solve() {
  for (int i = 1; i <= n; i++) a[i].d = cal(a[i], a[0]);
  sort(a + 1, a + n + 1, cmp);
  build(1, 1, n);
  for (int i = 0; i <= ans; i++) update(1, 1, n, a[q[i]].p, a[q[i]].r);
}
int main() {
  init();
  solve();
  printf("%d\n", ans);
  return 0;
}
