#include <bits/stdc++.h>
using namespace std;
using namespace rel_ops;
const double PI = acos((double)-1);
int ts, ts2, ts3, ts4;
int q2[35], n, m;
long long gcd(long long x, long long y) {
  long long t;
  for (; y != 0;) {
    t = x % y;
    x = y;
    y = t;
  }
  return x;
}
double sqr(double x) { return x * x; }
template <class T>
void mn(T& x, T y) {
  x = min(x, y);
}
template <class T>
void mx(T& x, T y) {
  x = max(x, y);
}
struct magnet {
  long long d, cand, m, canm;
} b[500005];
vector<int> Ve;
pair<long long, long long> ord[1000005];
int hav[1000005];
queue<int> Qu;
struct segTree {
  struct node {
    long long l, r, v, dy, maxd;
  } a[300000 * 4];
  void create(int k, int l, int r) {
    a[k].l = l, a[k].r = r;
    a[k].v = 0;
    int mid = (a[k].l + a[k].r) / 2;
    if (l == r) {
      a[k].dy = ord[l].second;
      a[k].v = b[ord[l].second].m;
      a[k].maxd = b[ord[l].second].d;
      return;
    }
    create(k * 2, l, mid);
    create(k * 2 + 1, mid + 1, r);
    a[k].v = min(a[k * 2].v, a[k * 2 + 1].v);
    a[k].maxd = min(a[k * 2 + 1].maxd, a[k * 2].maxd);
  }
  int update(int k, int p) { int mid = (a[k].l + a[k].r) / 2; }
  void ask(int k, int p) {
    int mid = (a[k].l + a[k].r) / 2;
    if (a[k].maxd > b[p].cand || a[k].v > b[p].canm) return;
    if (a[k].l == a[k].r) {
      int t1 = a[k].dy;
      hav[t1] = 1;
      a[k].v = 200000000000000000ll;
      a[k].maxd = 200000000000000000ll;
      Qu.push(t1);
      return;
    }
    ask(k * 2, p);
    ask(k * 2 + 1, p);
    a[k].v = min(a[k * 2].v, a[k * 2 + 1].v);
    a[k].maxd = min(a[k * 2 + 1].maxd, a[k * 2].maxd);
  }
} s;
int main() {
  long long i, j, k, l, t1, t2, t3, t4, t5, t6, t7, t8, t9, t, nw, ans = 0;
  int tt1, tt2, tt3, tt4;
  double u1, u2, u3, u4, u5, u6, u7, u8, u9;
  char c1, c2, c3;
  for (q2[0] = 1, i = 1; i < 35; q2[i] = q2[i - 1] * 2, i++)
    ;
  srand((unsigned)time(0));
  cin >> u1 >> u2 >> b[0].canm >> b[0].cand >> n;
  for (i = 1; i <= n; i++) {
    scanf(
        "%lld"
        "%lld"
        "%lld"
        "%lld"
        "%lld",
        &t1, &t2, &t3, &t4, &t5);
    b[i].d = (long long)(sqrt(sqr(t1 - u1) + sqr(t2 - u2)) - 1E-10) + 1;
    b[i].m = t3;
    b[i].canm = t4;
    b[i].cand = t5;
    Ve.push_back(b[i].d);
    ord[i] = make_pair(b[i].d, i);
  }
  sort(Ve.begin(), Ve.end());
  t1 = unique(Ve.begin(), Ve.end()) - Ve.begin();
  sort(ord + 1, ord + n + 1);
  s.create(1, 1, n);
  Qu.push(0);
  for (; !Qu.empty();) {
    int nw = Qu.front();
    Qu.pop();
    s.ask(1, nw);
  }
  for (i = 1; i <= n; i++)
    if (hav[i]) ans++;
  cout << ans << endl;
  return 0;
}
