#include <bits/stdc++.h>
using namespace std;
pair<long long, int> inf = make_pair(9000000000000000000ll, 0);
pair<pair<int, int>, pair<int, long long> > q[333333];
int e[333333], x0, Y0, q1, q2, ans, u[333333], n, x, y;
pair<long long, int> s[1999999];
void init(int pos, int l, int r) {
  if (l == r) {
    s[pos] = make_pair(q[l].second.second, l);
    return;
  }
  init(pos + pos, l, (l + r) / 2);
  init(pos + pos + 1, (l + r) / 2 + 1, r);
  s[pos] = min(s[pos + pos], s[pos + pos + 1]);
}
void deel(int pos, int l, int r, int v) {
  if (v < l || v > r) return;
  if (l == r) {
    s[pos] = make_pair(9000000000000000000ll, 0);
    return;
  }
  deel(pos + pos, l, (l + r) / 2, v);
  deel(pos + pos + 1, (l + r) / 2 + 1, r, v);
  s[pos] = min(s[pos + pos], s[pos + pos + 1]);
}
pair<long long, int> find(int pos, int l, int r, int v) {
  if (v < l) return inf;
  if (v >= r) return s[pos];
  return min(find(pos + pos, l, (l + r) / 2, v),
             find(pos + pos + 1, (l + r) / 2 + 1, r, v));
}
int main() {
  cin >> x0 >> Y0 >> q[0].first.second >> q[0].second.first >> n;
  q[0].first.first = 0;
  q[0].second.second = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d%d%d", &x, &y, &q[i].first.first, &q[i].first.second,
          &q[i].second.first);
    q[i].second.second = (x0 - x) * 1ll * (x0 - x) + (Y0 - y) * 1ll * (Y0 - y);
  }
  sort(q, q + n + 1);
  for (int i = 0; i <= n; i++) e[i] = q[i].first.first;
  init(1, 0, n + 1);
  deel(1, 0, n + 1, 0);
  q1 = 0;
  q2 = 1;
  u[0] = 0;
  while (q1 < q2) {
    int x = upper_bound(e, e + n + 1, q[u[q1]].first.second) - e - 1;
    long long r = q[u[q1]].second.first;
    r *= r;
    pair<long long, int> ee = find(1, 0, n + 1, x);
    while (ee.first <= r) {
      ans++;
      u[q2++] = ee.second;
      deel(1, 0, n + 1, ee.second);
      ee = find(1, 0, n + 1, x);
    }
    q1++;
  }
  cout << (ans) << endl;
  return 0;
}
