#include <bits/stdc++.h>
using namespace std;
long long sqr(long long x) { return x * x; }
long long dist(pair<int, int> a, pair<int, int> b) {
  return sqr(a.first - b.first) + sqr(a.second - b.second);
}
const int N = 250000 + 987, inf = 0x3f3f3f3f;
struct gp {
  int m, p, r;
} a[N];
int n;
long long d[N];
int idx[N];
int t[N * 4];
int gi(long long x) {
  int lo = 0, hi = n - 1;
  while (lo <= hi) {
    int mi = (lo + hi) / 2;
    if (d[idx[mi]] <= x)
      lo = mi + 1;
    else
      hi = mi - 1;
  }
  return hi;
}
int mi(int i, int j) { return a[idx[i]].m < a[idx[j]].m ? i : j; }
void pull(int o) { t[o] = mi(t[o << 1], t[o << 1 | 1]); }
void bld(int o = 1, int l = 0, int r = n) {
  if (r - l == 1) {
    t[o] = l;
    return;
  }
  int m = (l + r) >> 1;
  bld(o << 1, l, m);
  bld(o << 1 | 1, m, r);
  pull(o);
}
int qry(int i, int j, int o = 1, int l = 0, int r = n) {
  if (j <= l || r <= i) return n;
  if (i <= l && r <= j) return t[o];
  int m = (l + r) / 2;
  return mi(qry(i, j, o << 1, l, m), qry(i, j, o << 1 | 1, m, r));
}
void upd(int i, int o = 1, int l = 0, int r = n) {
  if (r - l == 1) {
    t[o] = n;
    return;
  }
  int m = (l + r) >> 1;
  if (i < m)
    upd(i, o << 1, l, m);
  else
    upd(i, o << 1 | 1, m, r);
  pull(o);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  pair<int, int> p;
  {
    gp fyk;
    cin >> p.first >> p.second >> fyk.p >> fyk.r >> n;
    a[n].m = inf;
    a[n].p = fyk.p;
    a[n].r = fyk.r;
  }
  for (int i = 0; i < n; ++i) {
    pair<int, int> u;
    cin >> u.first >> u.second >> a[i].m >> a[i].p >> a[i].r;
    d[i] = dist(u, p);
    idx[i] = i;
  }
  idx[n] = n;
  sort(idx, idx + n, [&](int i, int j) -> bool { return d[i] < d[j]; });
  for (int i = 0; i <= n; ++i) a[i].r = gi(sqr(a[i].r));
  bld();
  vector<int> v{n};
  for (int x = 0; x < ((int)(v).size()); ++x) {
    int i = v[x];
    int j;
    while ((j = qry(0, a[idx[i]].r + 1)) < n && a[idx[j]].m <= a[idx[i]].p) {
      v.push_back(j);
      upd(j);
    }
  }
  cout << ((int)(v).size()) - 1 << '\n';
}
