#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r, fix;
  pair<int, int> key;
} p[(250100) * 20];
int size(-1);
class treap {
 public:
  int root;
  treap() { root = -1; }
  void rot_l(int &x) {
    int y = p[x].r;
    p[x].r = p[y].l;
    p[y].l = x;
    x = y;
  }
  void rot_r(int &x) {
    int y = p[x].l;
    p[x].l = p[y].r;
    p[y].r = x;
    x = y;
  }
  void insert(int &k, pair<int, int> tkey) {
    if (k == -1) {
      k = ++size;
      p[k].l = p[k].r = -1;
      p[k].key = tkey;
      p[k].fix = rand();
    } else if (tkey < p[k].key) {
      insert(p[k].l, tkey);
      if (p[p[k].l].fix > p[k].fix) rot_r(k);
    } else {
      insert(p[k].r, tkey);
      if (p[p[k].r].fix > p[k].fix) rot_l(k);
    }
  }
  void remove(int &k, pair<int, int> tkey) {
    if (k == -1) return;
    if (tkey < p[k].key)
      remove(p[k].l, tkey);
    else if (tkey > p[k].key)
      remove(p[k].r, tkey);
    else {
      if (p[k].l == -1 && p[k].r == -1)
        k = -1;
      else if (p[k].l == -1)
        k = p[k].r;
      else if (p[k].r == -1)
        k = p[k].l;
      else if (p[p[k].l].fix < p[p[k].r].fix) {
        rot_l(k);
        remove(p[k].l, tkey);
      } else {
        rot_r(k);
        remove(p[k].r, tkey);
      }
    }
  }
  int Find(int pos) {
    int t = root;
    if (t == -1) return 0;
    while (p[t].l != -1) t = p[t].l;
    if (p[t].key.first <= pos) return p[t].key.second;
    return 0;
  }
} Tree[(250100) * 2];
struct Point {
  int d, m, p, r;
} po[(250100)];
int n, X_cnt, Y_cnt, V_cnt;
int base_x, base_y;
int Q[(250100)];
long long dist[(250100)];
pair<long long, int> V[(250100) * 2];
inline int input() {
  int tmp = 0;
  char ch = getchar();
  bool flag(true);
  while (ch != '-' && (ch < '0' || '9' < ch)) ch = getchar();
  if (ch == '-') flag = false, ch = getchar();
  while ('0' <= ch && ch <= '9')
    tmp = (tmp << 3) + (tmp << 1) + (ch - '0'), ch = getchar();
  return flag ? tmp : -tmp;
}
inline long long sqr(long long num) { return num * num; }
void Input() {
  base_x = input(), base_y = input();
  po[0].d = 0, po[0].m = 0, po[0].p = input(), po[0].r = input();
  n = input();
  for (int i = 1, xx, yy; i <= n; i++) {
    xx = input(), yy = input();
    po[i].m = input(), po[i].p = input(), po[i].r = input();
    dist[i] = sqr(xx - base_x) + sqr(yy - base_y);
  }
  V_cnt = 0, X_cnt = 0;
  for (int i = 0; i <= n; i++) {
    V[V_cnt++] = make_pair(dist[i], i << 1);
    V[V_cnt++] = make_pair(sqr(po[i].r), i << 1 | 1);
  }
  sort(V, V + V_cnt);
  long long last = V[0].first - 1;
  for (int i = 0; i < V_cnt; i++) {
    if (last != V[i].first) {
      last = V[i].first;
      X_cnt++;
    }
    int idx = V[i].second;
    if (idx & 1)
      po[idx >> 1].r = X_cnt;
    else
      po[idx >> 1].d = X_cnt;
  }
  V_cnt = 0, Y_cnt = 0;
  for (int i = 0; i <= n; i++) {
    V[V_cnt++] = make_pair(po[i].m, i << 1);
    V[V_cnt++] = make_pair(po[i].p, i << 1 | 1);
  }
  sort(V, V + V_cnt);
  last = V[0].first - 1;
  for (int i = 0; i < V_cnt; i++) {
    if (last != V[i].first) {
      last = V[i].first;
      Y_cnt++;
    }
    int idx = V[i].second;
    if (idx & 1)
      po[idx >> 1].p = Y_cnt;
    else
      po[idx >> 1].m = Y_cnt;
  }
}
void Insert(int idx, int pos, int value) {
  while (idx <= X_cnt) {
    Tree[idx].insert(Tree[idx].root, make_pair(pos, value));
    idx += idx & -idx;
  }
}
int Find(int idx, int pos) {
  int tmp;
  while (idx > 0) {
    tmp = Tree[idx].Find(pos);
    if (tmp != 0) return tmp;
    idx -= idx & -idx;
  }
  return 0;
}
void Delete(int idx, int pos, int value) {
  while (idx <= X_cnt) {
    Tree[idx].remove(Tree[idx].root, make_pair(pos, value));
    idx += idx & -idx;
  }
}
void Solve() {
  register int i, u, v;
  for (i = 1; i <= n; i++) {
    Insert(po[i].d, po[i].m, i);
  }
  int Head(0), Tail(0);
  Q[Tail++] = 0;
  while (Head < Tail) {
    u = Q[Head++];
    while ((v = Find(po[u].r, po[u].p)) != 0) {
      Delete(po[v].d, po[v].m, v);
      Q[Tail++] = v;
    }
  }
  printf("%d\n", Tail - 1);
}
int main() {
  srand(233);
  Input();
  Solve();
  return 0;
}
