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

const int N=1e5+20;

int n,u,v,a,b,dp[2][N],ans;
vector <int> adj[N];
queue <int> q;
bool vis[2][N];

void bfs(int node,int idx)
{
	q.push(node);
	vis[idx][node]=true;
	dp[idx][node]=0;

	while(not q.empty())
	{
		int node=q.front();
		q.pop();

		for(auto child:adj[node])
		{
			if(vis[idx][child]) continue;
			q.push(child);
			vis[idx][child]=true;
			dp[idx][child]=dp[idx][node]+1;
		}
	}
}

int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for(int i=0;i<n-1;i++)
	{
		scanf("%d%d",&u,&v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	u=a,v=b;
	bfs(u,0),bfs(v,1);
	for(int i=1;i<=n;i++)
	{
		if(dp[0][i]<=dp[1][i])
			ans=max(ans,dp[1][i]-1);
	}
	printf("%d",ans);
}