#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
const double EPS = 1e-8;

typedef complex<double> Point;
Point input(){
    double x, y;
    cin >> x >> y;
    return Point(x, y);
}
struct Circle{
    Point p;
    double r;
    Circle(Point p_, double r_) : p(p_), r(r_) {}
    bool operator < (const Circle & c) const {
        return r < c.r;
    }
    bool contain(const Circle& c) const {
        double d = abs(p - c.p);
        return r > c.r && r - c.r > d;
    }
    bool contain(const Point& pt) const {
        double d = abs(p - pt);
        return d < r;
    }
    bool cross(const Circle & c) const {
        double d = abs(p - c.p);
        return !contain(c) && r + c.r > d - EPS;
    }
};

vector<int> calc_dp(int n, vector<Circle> c, Circle d = Circle(Point(1e8, 1e8), 0)){
    assert(n == c.size());
    if(n == 0) return vector<int>(1, 0);
    vector<int> dp(n);
    for(int i = 0; i < n; i++){
        if(d.r > 0 && c[i].cross(d)) continue;
        dp[i] = 1;
        for(int j = 0; j < i; j++){
            if(c[i].contain(c[j])){
                dp[i] = max(dp[i], dp[j] + 1);
            }
        }
    }
    return dp;
}
int main(){
    int n;
    while(cin >> n && n){
        Point sp = input();
        Point tp = input();
        vector<Circle> sc, tc;
        REP(i, n){
            Point p = input();
            double r;
            cin >> r;
            Circle c(p, r);
            bool sb = c.contain(sp);
            bool tb = c.contain(tp);
            if(sb && tb) continue;
            if(sb) sc.push_back(c);
            if(tb) tc.push_back(c);
        }
        sort(sc.begin(), sc.end());
        sort(tc.begin(), tc.end());
        int sn = sc.size();
        int tn = tc.size();
        vector<int> sdp = calc_dp(sn, sc);
        vector<int> tdp = calc_dp(tn, tc);
        int ans = 0;
        ans = max(ans, *max_element(sdp.begin(), sdp.end()));
        ans = max(ans, *max_element(tdp.begin(), tdp.end()));
        for(int i = 0; i < sn; i++){
            for(int j = 0; j < tn; j++){
                if(!sc[i].cross(tc[j])){
                    ans = max(ans, sdp[i] + tdp[j]);
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}