#include<bits/stdc++.h>
#define MAXN 10010
#define MAXY 2010
#define INF 0x3f3f3f
const int MOD=1e9+7;
const double eps=1e-8;
typedef long long ll;
//orz yht
using namespace std;
vector<int> e[100005];
int n,s,t;
int dep[100005],md[100005],fa[100005];
void dfs(int u,int f){
	dep[u]=md[u]=dep[f]+1;
	fa[u]=f;
	for(auto v:e[u])
	if(v!=f){
		dfs(v,u);
		md[u]=max(md[u],md[v]);
	}
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>s>>t;
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	dfs(t,0);
	int ans=0,x=s;
	while(1){
		if(dep[s]-dep[x]>=dep[x]-dep[t])
		break;
		ans=max(ans,md[x]-1);
		x=fa[x];
	}
	cout<<ans-1;
	return 0;
}