#include <bits/stdc++.h>
using namespace std;
const long long inf64 = ~0ull >> 2;
const int N = 500050;
struct gripper {
  long long d, m, p, r;
} dt[N];
bool operator<(const gripper &a, const gripper &b) { return a.d < b.d; }
int removed[N], res;
queue<int> que;
struct tree {
  int l, r;
  long long mv;
  tree *lc, *rc;
  tree(int _l, int _r) {
    l = _l, r = _r;
    mv = inf64;
    lc = rc = 0;
  }
  void build() {
    if (l == r) {
      mv = dt[l].m;
      return;
    }
    int m = (l + r) >> 1;
    (lc = new tree(l, m))->build();
    (rc = new tree(m + 1, r))->build();
    mv = min(lc->mv, rc->mv);
  }
  void update(long long p, long long ms) {
    if (ms < mv) return;
    if (l == r) {
      if (removed[l]) throw;
      removed[l] = 1, ++res, que.push(l);
      mv = inf64;
      return;
    }
    lc->update(p, ms);
    if (p >= rc->l) rc->update(p, ms);
    mv = min(lc->mv, rc->mv);
  }
} * rt;
template <class T>
struct cmpr_t {
  vector<T> z;
  void add(T x) { z.push_back(x); }
  void finish() { sort(z.begin(), z.end()); }
  int ub(T x) { return upper_bound(z.begin(), z.end(), x) - z.begin(); }
};
cmpr_t<long long> C;
int n;
int main() {
  long long x, y, x0, y0;
  cin >> x0 >> y0 >> dt[0].p >> dt[0].r >> n;
  dt[0].r *= dt[0].r;
  for (int i = (1); i <= (n); ++i) {
    cin >> x >> y >> dt[i].m >> dt[i].p >> dt[i].r;
    x -= x0, y -= y0;
    dt[i].d = x * x + y * y;
    dt[i].r *= dt[i].r;
    C.add(dt[i].d);
  }
  sort(dt + 1, dt + n + 1);
  C.finish();
  (rt = new tree(1, n))->build();
  que.push(0);
  while (!que.empty()) {
    int f = que.front();
    que.pop();
    rt->update(C.ub(dt[f].r), dt[f].p);
  }
  cout << res << endl;
  return 0;
}
