#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;

const int nax = 1e5+5;
vector<int> edges[nax];
int d1[nax],d2[nax];

void dfs(int u, int p,int d[]){
	d[u]=d[p]+1;
	for(auto x:edges[u]){
		if(x!=p) dfs(x,u,d);
	}
}

int32_t main(){
    vaibhavv06;
    
	int n; cin>>n;
	int t,a; cin>>t>>a;
	for(int i=1;i<n;i++){
		int a,b; cin>>a>>b;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}

	d1[0]=-1;
	d2[0]=-1;
	dfs(t,0,d1);
	dfs(a,0,d2);
	int ans=0;
	for(int i=1;i<=n;i++){
		if(d1[i]<d2[i]){
			ans=max(ans,d2[i]-1);
		}
	}
	cout<<ans<<endl;
}
