#include <bits/stdc++.h>
using namespace std;
struct st {
  int m, c, d;
  double dis;
  bool operator<(const st& s) const {
    return m < s.m || (m == s.m && dis < s.dis);
  }
} sw[250001];
st cp;
int oo = 1e9 + 1;
int tl[1000000], tr[1000000], h, t, a[500000], b[500000], n;
long long xx, yy, x, y;
double tmi[1000000];
void build(int p, int l, int r) {
  tl[p] = l;
  tr[p] = r;
  if (l != r) {
    int mi = (l + r) / 2;
    build(p * 2, l, mi);
    build(p * 2 + 1, mi + 1, r);
    tmi[p] = min(tmi[p * 2], tmi[p * 2 + 1]);
  } else
    tmi[p] = sw[l].dis;
}
void work(int p, int x) {
  if (tl[p] == tr[p]) {
    if (tmi[p] <= x) {
      a[++t] = sw[tl[p]].c;
      b[t] = sw[tl[p]].d;
      tmi[p] = oo;
    }
    return;
  }
  if (tmi[p * 2] <= x) work(p * 2, x);
  if (tmi[p * 2 + 1] <= x) work(p * 2 + 1, x);
  tmi[p] = min(tmi[p * 2], tmi[p * 2 + 1]);
}
void renew(int p, int l, int r, int xx) {
  if (r < l) return;
  if (tl[p] == l && tr[p] == r) {
    work(p, xx);
    return;
  }
  int mi = (tl[p] + tr[p]) / 2;
  if (mi < l)
    renew(p * 2 + 1, l, r, xx);
  else if (mi >= r)
    renew(p * 2, l, r, xx);
  else
    renew(p * 2, l, mi, xx), renew(p * 2 + 1, mi + 1, r, xx);
  tmi[p] = min(tmi[p * 2], tmi[p * 2 + 1]);
}
int main() {
  scanf("%I64d%I64d%d%d%d", &xx, &yy, &a[1], &b[1], &n);
  int i;
  for (i = 1; i <= n; i++) {
    scanf("%I64d%I64d%d%d%d", &x, &y, &sw[i].m, &sw[i].c, &sw[i].d);
    sw[i].dis = sqrt((x - xx) * (x - xx) + (y - yy) * (y - yy));
  }
  t = 1;
  sort(sw + 1, sw + n + 1);
  build(1, 1, n);
  for (h = 0; h < t;) {
    h++;
    cp.m = a[h];
    cp.dis = b[h];
    renew(1, 1, upper_bound(sw + 1, sw + n + 1, cp) - sw - 1, cp.dis);
  }
  cout << t - 1;
}
