#include<bits/stdc++.h>
using namespace std;

const int maxn=1e5+7;
int n,t,a;
int dist[maxn],disa[maxn],ans;
vector<int> to[maxn];

void dfs(int x,int f,int* dis)
{
	dis[x]=dis[f]+1;
	for(int i=0;i<to[x].size();++i) {
		int t=to[x][i];
		if(t==f) continue;
		dfs(t,x,dis);
	}
}

int main()
{
	scanf("%d %d %d",&n,&t,&a);
	for(int i=1;i<n;++i) {
		int u,v;
		scanf("%d %d",&u,&v);
		to[u].push_back(v);
		to[v].push_back(u);
	}
	dfs(t,0,dist);
	dfs(a,0,disa);
	for(int i=1;i<=n;++i) {
		if(dist[i]<disa[i]) {
			ans=max(ans,disa[i]-1);
		}
	}
	printf("%d",ans-1);
}