#include <bits/stdc++.h>
using namespace std;
const int maxn = 250005;
int qr[maxn], qp[maxn], wm[maxn], loc[maxn];
int pp[maxn], pr[maxn], pm[maxn];
long long pd[maxn];
stack<int> f[maxn];
bool used[maxn];
int n, nx, ny, totm;
long long dist(int x, int y) { return (long long)x * x + (long long)y * y; };
bool cmp(int a, int b) { return pd[a] > pd[b]; };
int main() {
  int i, x, y, h, t;
  long long d;
  scanf("%d%d%d%d%d", &nx, &ny, qp + 1, qr + 1, &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d%d%d%d%d", &x, &y, pm + i, pp + i, pr + i);
    pd[i] = dist(x - nx, y - ny);
    wm[i - 1] = pm[i];
    loc[i] = i;
  }
  sort(wm, wm + n);
  totm = unique(wm, wm + n) - wm;
  for (i = 1; i <= n; ++i) pm[i] = lower_bound(wm, wm + totm, pm[i]) - wm + 1;
  sort(loc + 1, loc + n + 1, cmp);
  for (i = 1; i <= n; ++i)
    for (x = pm[loc[i]]; x <= totm; x += x & -x) f[x].push(loc[i]);
  for (h = 1, t = 1; h <= t; ++h) {
    x = upper_bound(wm, wm + totm, qp[h]) - wm;
    d = (long long)qr[h] * qr[h];
    for (; x > 0; x -= x & -x)
      while (!f[x].empty() && pd[f[x].top()] <= d) {
        y = f[x].top();
        f[x].pop();
        if (!used[y]) {
          used[y] = true;
          ++t;
          qp[t] = pp[y];
          qr[t] = pr[y];
        }
      }
  }
  printf("%d\n", t - 1);
  return 0;
}
