#include <bits/stdc++.h>
using namespace std;
const long long inf = INT_MAX, df = 4e5 + 7;
priority_queue<pair<long long, long long>> que[df];
int i, j, k, l, m, n, o, q, s, t, u, v, w, x, y, z, tot, cur[df], pos[df];
long long r[df], p[df], d[df], b[df], a[df];
inline long long read() {
  long long x = 0, y = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') y = (ch == '-') ? -1 : 1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return x * y;
}
int main() {
  x = read(), y = read(), p[0] = read(), r[0] = read(), n = read();
  r[0] *= r[0], tot = 0;
  for (int i = (1); i <= (n); ++i) {
    s = read(), t = read(), m = read(), p[i] = read(), r[i] = read();
    d[i] = 1ll * (s - x) * (s - x) + 1ll * (t - y) * (t - y), r[i] *= r[i];
    b[i] = m;
    a[++tot] = m;
    pos[i] = 1;
  }
  sort(a + 1, a + tot + 1), tot = unique(a + 1, a + tot + 1) - a - 1;
  int cnt = 0;
  for (int i = (1); i <= (n); ++i)
    for (int j = lower_bound(a + 1, a + tot + 1, b[i]) - a; j <= tot;
         j += j & -j)
      que[j].push(make_pair(-d[i], i));
  for (cur[0] = i = 0; i <= cnt; ++i) {
    for (int j = upper_bound(a + 1, a + tot + 1, p[cur[i]]) - a - 1; j;
         j -= j & -j) {
      for (; (!que[j].empty()) && -que[j].top().first <= r[cur[i]];
           que[j].pop())
        if (pos[que[j].top().second]) pos[cur[++cnt] = que[j].top().second] = 0;
    }
  }
  return printf("%d\n", cnt), 0;
}
