#include <bits/stdc++.h>
using namespace std;
struct Gripper {
  int m, gd, gm;
  bool operator<(const Gripper& g) const { return false; }
};
long long x, y, p, r, n;
Gripper grip;
queue<Gripper> q;
pair<pair<long long, long long>, Gripper> grippers[250001];
const int MAXN = 1 << 18;
struct RQTree {
  int* a;
  RQTree() {
    a = new int[2 * MAXN];
    fill(a, a + 2 * MAXN, 0x3f3f3f3f);
  }
  void init(int i, int l, int r) {
    if (l < r) {
      int m = (l + r) / 2;
      init(2 * i, l, m);
      init(2 * i + 1, m + 1, r);
      a[i] = min(a[2 * i], a[2 * i + 1]);
    }
  }
  void init() { init(1, 0, MAXN - 1); }
  int take(int x, int y, int mass, int i, int l, int r) {
    if (y < l || r < x || a[i] > mass) return 0;
    if (l == r) {
      q.push(grippers[i - MAXN].second);
      a[i] = 0x3f3f3f3f;
      return 1;
    }
    int m = (l + r) / 2;
    int ret =
        take(x, y, mass, 2 * i, l, m) + take(x, y, mass, 2 * i + 1, m + 1, r);
    a[i] = min(a[2 * i], a[2 * i + 1]);
    return ret;
  }
  int take(int x, int y, int mass) { return take(x, y, mass, 1, 0, MAXN - 1); }
};
int main() {
  ios::sync_with_stdio(0);
  cin >> x >> y >> p >> r >> n;
  for (int i = 0; i < n; ++i) {
    long long xi, yi, mi, pi, ri;
    cin >> xi >> yi >> mi >> pi >> ri;
    xi -= x, yi -= y;
    grippers[i].first.first = xi * xi + yi * yi;
    grippers[i].first.second = ri * ri;
    grippers[i].second.m = mi;
    grippers[i].second.gm = pi;
  }
  sort(grippers, grippers + n);
  grip.m = 0, grip.gm = p,
  grip.gd = lower_bound(grippers, grippers + n,
                        make_pair(make_pair(r * r + 1, 0ll), grip)) -
            1 - grippers;
  q.push(grip);
  RQTree tree;
  for (int i = 0; i < n; ++i) {
    grippers[i].second.gd =
        lower_bound(
            grippers, grippers + n,
            make_pair(make_pair(grippers[i].first.second + 1, 0ll), grip)) -
        1 - grippers;
    tree.a[i + MAXN] = grippers[i].second.m;
  }
  tree.init();
  int ans = 0;
  while (!q.empty()) {
    grip = q.front();
    q.pop();
    ans += tree.take(0, grip.gd, grip.gm);
  }
  cout << ans << endl;
}
