#include <bits/stdc++.h>
const int N = 250000 + 9;
struct info {
  int p, r, m, idx;
  long long key;
} q[N], a[N], mem[N], temp1[N], temp2[N];
int ans, X, Y, tmp[N * 2], pos[N * 25], *t[N * 8], cnt, L, R, n, st[N * 8],
    ed[N * 8];
int h = 1, tail = 1;
bool inq[N];
long long radius;
inline long long dis(const long long x1, const long long y1, const long long x2,
                     const long long y2) {
  return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
}
inline bool operator<(const info &lhs, const info &rhs) {
  return lhs.key < rhs.key;
}
void query(const int idx, const int l, const int r) {
  if (L <= l && r <= R) {
    for (int &i = st[idx]; i <= ed[idx] && mem[t[idx][i]].key <= radius; ++i) {
      if (inq[mem[t[idx][i]].idx]) continue;
      q[++tail] = mem[t[idx][i]], ++ans;
      inq[mem[t[idx][i]].idx] = true;
    }
    return;
  }
  if (st[idx] > ed[idx]) return;
  const int mid = (l + r) / 2;
  if (L <= mid) query(idx * 2, l, mid);
  if (mid < R) query(idx * 2 + 1, mid + 1, r);
}
void build(const int idx, const int l, const int r, const int _l,
           const int _r) {
  t[idx] = pos + cnt;
  st[idx] = 1;
  if (_l > _r) return;
  for (int i = _l; i <= _r; ++i) pos[++cnt] = a[i].idx, ++ed[idx];
  if (l == r) return;
  const int mid = (l + r) / 2;
  int k1 = 0, k2 = 0;
  for (int i = _l; i <= _r; ++i)
    if (a[i].m <= mid)
      temp1[++k1] = a[i];
    else
      temp2[++k2] = a[i];
  for (int i = 1; i <= k1; ++i) a[i + _l - 1] = temp1[i];
  for (int i = 1; i <= k2; ++i) a[_l + k1 + i - 1] = temp2[i];
  build(idx * 2, l, mid, _l, _l + k1 - 1);
  build(idx * 2 + 1, mid + 1, r, _l + k1, _r);
}
int work() {
  while (h <= tail) {
    const info u = q[h++];
    radius = 1ll * u.r * u.r;
    L = 1, R = u.p;
    query(1, 1, tmp[0]);
  }
  return ans;
}
int main() {
  scanf("%d%d%d%d%d", &X, &Y, &q[1].p, &q[1].r, &n);
  tmp[++tmp[0]] = q[1].p;
  for (int i = 1, x, y; i <= n; ++i) {
    scanf("%d%d%d%d%d", &x, &y, &a[i].m, &a[i].p, &a[i].r);
    a[i].key = dis(X, Y, x, y);
    tmp[++tmp[0]] = a[i].m;
    tmp[++tmp[0]] = a[i].p;
  }
  std::sort(tmp + 1, tmp + 1 + tmp[0]);
  tmp[0] = std::unique(tmp + 1, tmp + 1 + tmp[0]) - tmp - 1;
  for (int i = 1; i <= n; ++i)
    a[i].m = std::lower_bound(tmp + 1, tmp + 1 + tmp[0], a[i].m) - tmp;
  for (int i = 1; i <= n; ++i)
    a[i].p = std::lower_bound(tmp + 1, tmp + 1 + tmp[0], a[i].p) - tmp;
  q[1].p = std::lower_bound(tmp + 1, tmp + 1 + tmp[0], q[1].p) - tmp;
  std::sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; ++i) a[i].idx = i;
  memcpy(mem, a, sizeof a);
  build(1, 1, tmp[0], 1, n);
  printf("%d\n", work());
}
