#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1005

enum Type{
	DOUBLE,
	NONE,
	START,
	GOAL,
};

struct Point{
	double x,y;
};

struct Circle{
	Point center;
	double r;
};

struct Info{
	Info(){
		id = 0;
		sum_value = 0;
	}
	Info(int arg_id,int arg_sum_value){
		id = arg_id;
		sum_value = arg_sum_value;
	}
	bool operator<(const struct Info &arg) const{//★内包数の降順★
		return sum_value < arg.sum_value;
	}
	int id,sum_value;
};

int N;
int dp[NUM],in_num[NUM];
Point start,goal;
Circle circle[NUM];
vector<int> G[NUM],start_group,goal_group;
Type type[NUM];

double calc_dist(Point a,Point b){
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

bool is_contain(Circle tmp_circle,Point a){
	double tmp_dist = calc_dist(tmp_circle.center,a);
	return tmp_dist <= tmp_circle.r;
}

bool is_contain(Circle child,Circle parent){
	return calc_dist(parent.center,child.center)+child.r < parent.r;
}

bool is_cross(Circle a,Circle b){
	return calc_dist(a.center,b.center) <= a.r+b.r;
}

void func(){

	start_group.clear();
	goal_group.clear();

	for(int i = 0; i < N; i++){
		G[i].clear();
		in_num[i] = 0;
	}

	scanf("%lf %lf %lf %lf",&start.x,&start.y,&goal.x,&goal.y);

	bool start_FLG,goal_FLG;

	for(int i = 0; i < N; i++){

		start_FLG = false;
		goal_FLG = false;

		scanf("%lf %lf %lf",&circle[i].center.x,&circle[i].center.y,&circle[i].r);

		start_FLG = is_contain(circle[i],start);
		goal_FLG = is_contain(circle[i],goal);

		if(start_FLG == true && goal_FLG == true){

			type[i] = DOUBLE;

		}else if(start_FLG == true && goal_FLG == false){

			type[i] = START;
			start_group.push_back(i);

		}else if(start_FLG == false && goal_FLG == true){

			type[i] = GOAL;
			goal_group.push_back(i);

		}else{ //start_FLG == false && goal_FLG == false

			type[i] = NONE;
		}
	}

	//円と円の内包関係を求める
	for(int i = 0; i < N; i++){
		if(type[i] == DOUBLE || type[i] == NONE)continue;
		for(int k = 0; k < N; k++){
			if(k == i || type[k] != type[i])continue; //種類が違うならSKIP

			if(is_contain(circle[i],circle[k])){
				G[i].push_back(k);
				in_num[k]++;//有向辺の入次数をインクリメント
			}
		}
	}

	//ある最外円に対する、最大の内包数を調べる
	for(int i = 0; i < N; i++)dp[i] = 0;

	priority_queue<Info> Q;
	for(int i = 0; i < N; i++){
		if(type[i] == START || type[i] == GOAL){
			if(in_num[i] == 0){ //★他の円を含んでいない円がDAGの始点★
				Q.push(Info(i,0));
			}
		}
	}
	int next_id;

	Info info;

	while(!Q.empty()){
		info = Q.top();
		Q.pop();

		for(int i = 0; i < G[info.id].size(); i++){

			next_id = G[info.id][i];
			if(dp[next_id] < info.sum_value+1){
				dp[next_id] =info.sum_value+1;
				Q.push(Info(next_id,dp[next_id]));
			}
		}
	}

	int start_max = 0,goal_max = 0;
	for(int i = 0; i < N; i++){
		if(type[i] == DOUBLE || type[i] == NONE)continue;

		if(type[i] == START){

			start_max = max(start_max,dp[i]+1);

		}else{

			goal_max = max(goal_max,dp[i]+1);
		}
	}

	if(start_group.size() == 0 || goal_group.size() == 0){
		printf("%d\n",max(start_max,goal_max));
		return;
	}

	int a,b;
	int ans = max(start_max,goal_max); //★★交差しない、start包円とgoa包円lの組合せがない場合に備えた処理★★

	for(int i = 0; i < start_group.size(); i++){
		a = start_group[i];
		for(int k = 0; k < goal_group.size(); k++){
			b = goal_group[k];

			if(is_cross(circle[a],circle[b]))continue;

			ans = max(ans,dp[a]+dp[b]+2);
		}
	}

	printf("%d\n",ans);
}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 7356