//#include<iostream>
//#include<cstdio> 
//#include<cstring>
//#include<stack>
//#include<queue>
//#include<set>
//#include<map>
//#include<vector>
//#include<list>
//#include<cmath>
//#include<algorithm>
//#define lson node<<1,st,mid
//#define rson node<<1|1,mid+1,ed
//#define mem(a,x) memset(a,x,sizeof(a))
//#define me(a) memset(a,0,sizeof(a))
//#define IOS ios::sync_with_stdio(false)
//#define lowbit(x) x&(-x)
//typedef long long ll;
//const ll mod=1e9+7;
//const ll INF=0x3f3f3f3f;
//const ll maxn=1e6+5;
//const double pi = acos(-1.0);
//using namespace std;
//ll a[50],b[50];
//ll main(){
//	ll n;
////	a[1]=1;
////	a[2]=2;
////	a[3]=3;
////	for(ll i=4;i<=100;i++){
////		a[i]=i*a[i-2];
////	}
////	for(ll i=1;i<=100;i++){
////		cout<<a[i]<<endl;
////	}
//	a[0]=0;
//	b[0]=0;
//	b[1]=9;b[2]=99;b[3]=999;b[4]=9999;b[5]=99999;b[6]=999999;
//	b[7]=9999999;b[8]=99999999;b[9]=999999999;b[10]=9999999999;b[11]=99999999999;b[12]=999999999999;
//	b[13]=9999999999999;b[14]=99999999999999;b[15]=999999999999999;b[16]=9999999999999999;b[17]=99999999999999999;b[18]=999999999999999999;
//	b[19]=9999999999999999999;
//	
//	for(ll i=1;i<=20;i++){
//		a[i]+=b[i];
//	}
//	cin>>n;
//	if(n<10) cout<<"0"<<endl;
//	else{
//		if(n%2==0) {
//			ll ans=lower(a,a+20,n)-a;
//			if()
//		}
//		else cout<<"0"<<endl;
//	}
//	
//}
#include<iostream>
#include<cstdio> 
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<fstream>
#include<sstream>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
typedef long long ll;
const ll mod=1e9+7;
const ll INF=0x3f3f3f3f;
const ll maxn=1e5+5;
const double pi = acos(-1.0);
using namespace std;
ll n,m;
ll dist[maxn],head[maxn];
bool vis[maxn];
struct code{
	ll to,w,next;
}edge[maxn];
struct node{
	ll to,w;
	bool operator <(const node &x) const{
		return w>x.w;
	}
};
priority_queue<node>q;
ll cnt;
void lln(){
	cnt=0;
	mem(head,-1);
	mem(vis,false);
	mem(dist,INF);
	
}
void add(ll u,ll v,ll w){
	cnt++;
	edge[cnt].to=v;
	edge[cnt].w=w;
	edge[cnt].next=head[u];
	head[u]=cnt;
}
void dijkstra(ll u){
	dist[u]=0;
	q.push(node {u,dist[u]});
	
	while(!q.empty()){
		node x=q.top();
		q.pop();
		if(vis[x.to]) continue;
		vis[x.to]=true;
		for(ll i=head[x.to];i!=-1;i=edge[i].next){
			ll v=edge[i].to;
			if(dist[v]>dist[x.to]+edge[i].w){
				dist[v]=dist[x.to]+edge[i].w;
				q.push(node {v,dist[v]});
			}
		}
	}
}
int main(){
	ll n,x,y;
	cin>>n>>x>>y;
	if(x==y) cout<<"0"<<endl;
	else{
		intn();
		n--;
		while(n--){
			ll u,v,w;
			scanf("%lld%lld",&u,&v);
			add(u,v,1);
			add(v,u,1);
		}
		dijkstra(x);
		ll res=dist[y];
		if(res%2==0) cout<<res/2<<endl;
		else if(res==1&&abs(x-y)==1) cout<<"0"<<endl;
		else cout<<res/2+1<<endl;
	}
	
}