#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 2.5e5 + 20;
struct Gripper {
  ll d, m, r, p;
  int i;
  Gripper(ll d = 0, ll m = 0, ll r = 0, ll p = 0, int i = 0)
      : d(d), m(m), r(r), p(p), i(i) {}
  bool operator<(Gripper rhs) const { return d < rhs.d; }
};
int n;
ll x_0, y_0, r_0, p_0, curp[MAXN], curd[MAXN];
Gripper a[MAXN];
class ST {
  struct Node {
    int l, r, sum;
    set<pair<ll, int>> ent;
  };
  Node t[MAXN * 4];
  bool used[MAXN];

 public:
  void build(int, int, int);
  void take_all(int, int, ll, int&);
};
void ST::build(int u, int l, int r) {
  t[u].l = l;
  t[u].r = r;
  t[u].sum = r - l + 1;
  for (int i = l; i <= r; i++) t[u].ent.emplace(a[i].m, i);
  if (l == r) return;
  int mid = (l + r) / 2;
  build(u * 2, l, mid);
  build(u * 2 + 1, mid + 1, r);
}
void ST::take_all(int u, int p, ll d, int& full) {
  if (!t[u].sum || a[t[u].l].d > d) return;
  if (a[t[u].r].d <= d) {
    while (t[u].sum && t[u].ent.begin()->first <= p) {
      auto it = t[u].ent.begin();
      int cur = it->second;
      if (!used[cur]) {
        used[cur] = true;
        curp[++full] = a[cur].p;
        curd[full] = a[cur].r * a[cur].r;
      }
      t[u].ent.erase(it);
      t[u].sum--;
    }
  } else {
    take_all(u * 2, p, d, full);
    take_all(u * 2 + 1, p, d, full);
  }
}
ST t;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> x_0 >> y_0 >> p_0 >> r_0 >> n;
  for (int i = 1; i <= n; i++) {
    ll x, y, m, p, r;
    cin >> x >> y >> m >> p >> r;
    a[i] = {(x - x_0) * (x - x_0) + (y - y_0) * (y - y_0), m, r, p, i};
  }
  sort(a + 1, a + n + 1);
  t.build(1, 1, n);
  curp[0] = p_0;
  curd[0] = r_0 * r_0;
  int full = 0;
  for (int i = 0; i <= full && full <= n; i++)
    t.take_all(1, curp[i], curd[i], full);
  cout << full << endl;
}
