#include <bits/stdc++.h>
using namespace std;
const int MaxN = 400005;
const double eps = 1e-7;
const double DINF = 1e100;
const int INF = 1000000006;
const long long LINF = 1000000000000000005ll;
int n, m, front, tail;
int x[MaxN], y[MaxN], que[MaxN];
bool vis[MaxN];
struct grip {
  long long dis, r;
  int m, p;
  bool operator<(const grip& b) const {
    return (dis < b.dis) || (dis == b.dis && m < b.m);
  }
} p[MaxN];
long long dis[MaxN];
void init() {
  int t;
  scanf("%d%d%d%d%d", &x[0], &y[0], &p[0].p, &t, &n);
  p[0].r = t;
  p[0].r = p[0].r * p[0].r;
  for (int i = 1; i <= n; ++i) {
    long long r;
    scanf("%d%d%d%d%d", x + i, y + i, &p[i].m, &p[i].p, &t);
    long long xx = (long long)(x[0] - x[i]) * (x[0] - x[i]);
    long long yy = (long long)(y[0] - y[i]) * (y[0] - y[i]);
    p[i].dis = xx + yy;
    dis[i - 1] = p[i].dis;
    r = t;
    p[i].r = r * r;
  }
  sort(dis, dis + n);
  sort(p + 1, p + n + 1);
}
struct segtree {
  vector<pair<int, int> > stack;
} T[MaxN * 4];
void build(int x, int l, int r) {
  if (l == r) {
    T[x].stack.push_back(make_pair(p[l].m, l));
    return;
  }
  int mid = (l + r) >> 1;
  build(((x << 1)), l, mid);
  build(((x << 1) + 1), mid + 1, r);
  int a = T[((x << 1))].stack.size(), b = T[((x << 1) + 1)].stack.size();
  for (int i = 0, j = 0; i < a || j < b;) {
    if (i == a ||
        (j < b && T[((x << 1))].stack[i] <= T[((x << 1) + 1)].stack[j]))
      T[x].stack.push_back(T[((x << 1) + 1)].stack[j]), ++j;
    else
      T[x].stack.push_back(T[((x << 1))].stack[i]), ++i;
  }
}
void go(int p, int l, int r, int i, int j, int m) {
  if (i == l && j == r) {
    while (!T[p].stack.empty()) {
      if (T[p].stack.empty()) break;
      pair<int, int> it = T[p].stack.back();
      if (vis[it.second]) {
        T[p].stack.pop_back();
      } else {
        if (it.first > m) break;
        que[++tail] = it.second;
        vis[it.second] = 1;
        T[p].stack.pop_back();
      }
    }
    return;
  }
  int mid = (l + r) >> 1;
  if (j <= mid)
    go(((p << 1)), l, mid, i, j, m);
  else if (i > mid)
    go(((p << 1) + 1), mid + 1, r, i, j, m);
  else {
    go(((p << 1)), l, mid, i, mid, m);
    go(((p << 1) + 1), mid + 1, r, mid + 1, j, m);
  }
}
int main() {
  init();
  build(1, 1, n);
  que[front = tail = 0] = 0;
  vis[0] = 1;
  for (; front <= tail; ++front) {
    int u = que[front];
    int t = upper_bound(dis, dis + n, p[u].r) - dis;
    if (t >= 1) go(1, 1, n, 1, t, p[u].p);
  }
  cout << tail << endl;
  return 0;
}
