#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ll long long
#define len(v) (int)(v.size())

using namespace std;

typedef pair<ll,ll> P;

class tsort {
public:
	vector<vector<int> > G;
	vector<int> deg,res;
	int V;
	tsort(int node_size){
		V = node_size;
		G.resize(node_size),deg.resize(node_size,0);
	}
	void add_edge(int from,int to){
		G[from].push_back(to);
		deg[to]++;
	}
 	bool solve() {
		queue<int> que;
		rep(i,V){
	        if(deg[i] == 0){
	            que.push(i);
	        }
	    }
		while(!que.empty()){
			int p = que.front();
	        que.pop();
			res.push_back(p);
			rep(i,G[p].size()){
	            if(--deg[G[p][i]] == 0){
	                que.push(G[p][i]);
	            }
	        }
		}
		return (*max_element(deg.begin(),deg.end()) != 0);
	}
};

ll dir(ll a,ll b,ll c,ll d)
{
    return (a-c)*(a-c)+(b-d)*(b-d);
}

bool in(ll a,ll b,ll c,ll d,ll e,ll f)
{
    return dir(a,b,d,e) < (f-c)*(f-c);
}

bool ok(ll a,ll b,ll c,ll d,ll e,ll f)
{
    return dir(a,b,d,e) > (c+f)*(c+f);
}

int dp1[1001],dp2[1001];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        ll xs,ys,xt,yt;
        cin >> xs >> ys >> xt >> yt;
        vector<ll> x(n),y(n),r(n);
        rep(i,n){
            cin >> x[i] >> y[i] >> r[i];
        }
        rep(i,n){
            dp1[i] = dp2[i] = 1;
        }
        vector<P> u,v;
        rep(i,n){
            if(dir(x[i],y[i],xs,ys) < r[i]*r[i]){
                if(dir(x[i],y[i],xt,yt) >= r[i]*r[i]){
                    u.push_back(P(r[i],i));
                }
            }else if(dir(x[i],y[i],xt,yt) < r[i]*r[i]){
                v.push_back(P(r[i],i));
            }
        }
        sort(u.begin(),u.end()),sort(v.begin(),v.end());
        tsort g1(n),g2(n);
        rep(i,len(u)){
            int id1 = u[i].second;
            for(int j=i+1;j<len(u);j++){
                int id2 = u[j].second;
                if(in(x[id1],y[id1],u[i].first,x[id2],y[id2],u[j].first)){
                    g1.add_edge(id2,id1);
                }
            }
        }
        g1.solve();
        int r1 = 0,r2 = 0;
        for(int i=len(g1.res)-1;i>=0;i--){
            int u = g1.res[i];
            for(int v : g1.G[u]){
                dp1[u] = max(dp1[u],dp1[v]+1);
            }
            r1 = max(r1,dp1[u]);
        }
        rep(i,len(v)){
            int id1 = v[i].second;
            for(int j=i+1;j<len(v);j++){
                int id2 = v[j].second;
                if(in(x[id1],y[id1],v[i].first,x[id2],y[id2],v[j].first)){
                    g2.add_edge(id2,id1);
                }
            }
        }
        g2.solve();
        for(int i=len(g2.res)-1;i>=0;i--){
            int u = g2.res[i];
            for(int v : g2.G[u]){
                dp2[u] = max(dp2[u],dp2[v]+1);
            }
            r2 = max(r2,dp2[u]);
        }
        int ans = 0;
        rep(i,len(u)){
            int a = u[i].second;
            rep(j,len(v)){
                int b = v[j].second;
                if(ok(x[a],y[a],r[a],x[b],y[b],r[b])){
                    ans = max(ans,dp1[a]+dp2[b]);
                }
            }
        }
        cout << max({ans,len(u)?r1:0,len(v)?r2:0}) << "\n";
    }
}



Measured memory_bytes: 5760