#include <bits/stdc++.h>
using namespace std;
const int MAXN = 250000;
const int INF = 0x3f3f3f3f;
template <class T>
void Read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = 0;
  while (c < '0' || '9' < c) {
    if (c == '-') flag = 1;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  if (flag) x = -x;
}
const double eps = 1e-6;
inline int Sign(const double x) {
  if (x < -eps)
    return -1;
  else if (x > eps)
    return 1;
  else
    return 0;
}
int sx, sy, sp, sr, n;
int dx[MAXN + 10], dy[MAXN + 10], m[MAXN + 10], p[MAXN + 10], r[MAXN + 10];
double dis[MAXN + 10], t[MAXN + 10];
queue<pair<int, int> > que;
vector<double> ls[MAXN + 10];
int bg[MAXN + 10];
bool cmp(const int &a, const int &b) { return Sign(dis[a] - dis[b]) < 0; }
int mn[MAXN * 4];
inline int updata(int a, int b) { return Sign(dis[a] - dis[b]) <= 0 ? a : b; }
void build(int x, int l, int r) {
  if (l == r) {
    if (ls[l].size())
      mn[x] = ls[l][bg[l]++];
    else
      mn[x] = 0;
  } else {
    int mid = (l + r) >> 1;
    build(x << 1, l, mid);
    build(x << 1 | 1, mid + 1, r);
    mn[x] = updata(mn[x << 1], mn[x << 1 | 1]);
  }
}
void insert(int x, int pos, int v, int ll, int rr) {
  if (ll == rr)
    mn[x] = v;
  else {
    int mid = (ll + rr) >> 1;
    if (pos <= mid)
      insert(x << 1, pos, v, ll, mid);
    else
      insert(x << 1 | 1, pos, v, mid + 1, rr);
    mn[x] = updata(mn[x << 1], mn[x << 1 | 1]);
  }
}
int query(int x, int l, int r, int ll, int rr) {
  if (l <= ll && rr <= r)
    return mn[x];
  else {
    int mid = (ll + rr) >> 1;
    int ret = 0;
    if (l <= mid) ret = updata(ret, query(x << 1, l, r, ll, mid));
    if (mid < r) ret = updata(ret, query(x << 1 | 1, l, r, mid + 1, rr));
    return ret;
  }
}
int main() {
  Read(sx), Read(sy), Read(sp), Read(sr), Read(n);
  for (int i = 1; i <= n; ++i) {
    Read(dx[i]), Read(dy[i]), Read(m[i]), Read(p[i]), Read(r[i]);
    dx[i] -= sx, dy[i] -= sy;
    dis[i] = sqrt(1.0 * dx[i] * dx[i] + 1.0 * dy[i] * dy[i]);
    t[i] = m[i];
  }
  sort(t + 1, t + n + 1);
  int len = unique(t + 1, t + n + 1) - t - 1;
  for (int i = 1; i <= n; ++i) {
    m[i] = lower_bound(t + 1, t + len + 1, m[i]) - t;
    ls[m[i]].push_back(i);
  }
  for (int i = 1; i <= len; ++i) {
    sort(ls[i].begin(), ls[i].end(), cmp);
    bg[i] = 0;
  }
  dis[0] = INF;
  build(1, 1, len);
  int ans = 0;
  que.push(make_pair(sp, sr));
  pair<int, int> now;
  int tp, mnp;
  while (!que.empty()) {
    now = que.front(), que.pop();
    while (true) {
      tp = upper_bound(t + 1, t + len + 1, now.first) - t - 1;
      mnp = tp > 0 ? query(1, 1, tp, 1, len) : 0;
      if (Sign(dis[mnp] - now.second) <= 0) {
        que.push(make_pair(p[mnp], r[mnp])), ++ans;
        if (bg[m[mnp]] < ls[m[mnp]].size())
          insert(1, m[mnp], ls[m[mnp]][bg[m[mnp]]++], 1, len);
        else
          insert(1, m[mnp], 0, 1, len);
      } else
        break;
    }
  }
  printf("%d\n", ans);
}
