int N,A,B;
vector<int> E[101010];
int D[101010][2];

void dfs(int cur,int pre,int d,int id) {
	D[cur][id]=d;
	FORR(e,E[cur]) if(e!=pre) dfs(e,cur,d+1,id);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B;
	A--,B--;
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	dfs(A,A,0,0);
	dfs(B,B,0,1);
	
	int ma=0;
	FOR(i,N) if(D[i][0]<D[i][1]) ma=max(ma,D[i][1]-1);
	cout<<ma<<endl;
	
}