#include <bits/stdc++.h>
using namespace std;
const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const long long MXLL = 4e18;
const int Sz = 1110111;
inline void Read_rap() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
inline void randomizer3000() {
  unsigned int seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);
}
void files(string problem) {
  if (fopen((problem + ".in").c_str(), "r")) {
    freopen((problem + ".in").c_str(), "r", stdin);
    freopen((problem + ".out").c_str(), "w", stdout);
  }
}
int n;
long long d[Sz], m[Sz], r[Sz], p[Sz];
bool used[Sz];
struct fenwick {
  int n;
  vector<vector<pair<int, int> > > t;
  fenwick(int n) : n(n), t(n + 1) {}
  void add(int x, int y, int id) {
    for (int i = x; i <= n; i |= (i + 1)) t[i].push_back(make_pair(y, id));
  }
  void preSort() {
    for (int i = 0; i <= n; i++)
      sort(t[i].begin(), t[i].end(),
           [](pair<int, int> a, pair<int, int> b) { return a > b; });
  }
  void expand(int x, int y, queue<int> &q) {
    for (int i = x; i >= 0; i = (i & (i + 1)) - 1) {
      while ((int)(t[i].size()) && t[i].back().first <= y) {
        int id = t[i].back().second;
        if (!used[id]) {
          used[id] = 1;
          q.push(id);
        }
        t[i].pop_back();
      }
    }
  }
};
int Bfs(int st) {
  fenwick T(2 * (n + 1));
  for (int i = 1; i <= n; i++) T.add(m[i], d[i], i);
  T.preSort();
  queue<int> q;
  q.push(st);
  int cnt = 0;
  while (!q.empty()) {
    int i = q.front();
    q.pop();
    int p = ::p[i];
    int r = ::r[i];
    T.expand(p, r, q);
    cnt++;
  }
  return cnt - 1;
}
void compress(long long a[], long long b[]) {
  static vector<long long> c;
  c.clear();
  for (int i = 0; i <= n; i++) {
    c.push_back(a[i]);
    c.push_back(b[i]);
  }
  sort(c.begin(), c.end());
  for (int i = 0; i <= n; i++)
    a[i] = lower_bound(c.begin(), c.end(), a[i]) - c.begin();
  for (int i = 0; i <= n; i++)
    b[i] = lower_bound(c.begin(), c.end(), b[i]) - c.begin();
}
long long dist(int x, int y) { return x * 1ll * x + y * 1ll * y; }
int main() {
  int sx, sy;
  scanf("%d %d %d %d %d", &sx, &sy, p + 0, r + 0, &n);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d %d %d %d %d", &x, &y, m + i, p + i, r + i);
    d[i] = dist(x - sx, y - sy);
  }
  for (int i = 0; i <= n; i++) r[i] *= r[i];
  compress(r, d);
  compress(p, m);
  cout << Bfs(0);
  return 0;
}
