#include <bits/stdc++.h>
using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Edge{
	int src,dst;
	Edge(){}
	Edge(int s,int d):src(s),dst(d){}
};
typedef vector<vector<Edge>> Graph;

void dfs(const Graph& g,int v,vi& vis,vi& order)
{
	if(vis[v]) return;
	vis[v]=1;
	for(auto e:g[v]) dfs(g,e.dst,vis,order);
	order.push_back(v);
}

int main()
{
	for(int n;cin>>n && n;){
		int rx,ry,cx,cy; cin>>rx>>ry>>cx>>cy;
		vi xs(n),ys(n),rs(n);
		rep(i,n) cin>>xs[i]>>ys[i]>>rs[i];
		
		// wallの周上にbedやlairはない
		rep(i,n){
			int dx=xs[i]-rx,dy=ys[i]-ry;
			assert(dx*dx+dy*dy!=rs[i]*rs[i]);
			dx=xs[i]-cx,dy=ys[i]-cy;
			assert(dx*dx+dy*dy!=rs[i]*rs[i]);
		}
		
		// n:rat, n+1:cat
		// u->v: uがvの内側にある（接してもいない）
		Graph g(n+2);
		rep(i,n) repi(j,i+1,n) if(rs[i]!=rs[j]){
			int u=i,v=j;
			if(rs[u]>rs[v]) swap(u,v);
			int dx=xs[v]-xs[u],dy=ys[v]-ys[u],dr=rs[v]-rs[u];
			// rs[u]+sqrt(dx*dx+dy*dy)<rs[v]
			if(dx*dx+dy*dy<dr*dr)
				g[u].emplace_back(u,v);
		}
		rep(i,n){
			int dx=xs[i]-rx,dy=ys[i]-ry;
			if(dx*dx+dy*dy<rs[i]*rs[i]) g[n].emplace_back(n,i);
			dx=xs[i]-cx,dy=ys[i]-cy;
			if(dx*dx+dy*dy<rs[i]*rs[i]) g[n+1].emplace_back(n+1,i);
		}
		
		vvi order(2);
		rep(i,2){
			vi vis(n+2);
			dfs(g,n+i,vis,order[i]);
			reverse(all(order[i]));
		}
		//dump(order[0]); dump(order[1]);
		
		vvi dist(2,vi(n+2,-1));
		rep(i,2){
			dist[i][n+i]=0;
			for(int u:order[i]) if(dist[i][u]!=-1) for(auto e:g[u]){
				int v=e.dst;
				dist[i][v]=max(dist[i][v],dist[i][u]+1);
			}
		}
		//dump(dist[0]); dump(dist[1]);
		
		int res=0;
		rep(i,n){
			if(dist[0][i]!=-1 && dist[1][i]==-1) res=max(res,dist[0][i]);
			if(dist[0][i]==-1 && dist[1][i]!=-1) res=max(res,dist[1][i]);
		}
		rep(i,n) rep(j,n) if(dist[0][i]!=-1 && dist[1][j]!=-1){
			int dx=xs[j]-xs[i],dy=ys[j]-ys[i],rsum=rs[i]+rs[j];
			// sqrt(dx*dx+dy*dy)>rs[i]+rs[j]
			if(dx*dx+dy*dy>rsum*rsum)
				res=max(res,dist[0][i]+dist[1][j]);
		}
		//printf("%d %d %d %d ",rx,ry,cx,cy);
		cout<<res<<endl;
	}
}