#include<bits/stdc++.h>
using namespace std;
vector<int> vv[100022];
int mh[100022],par[100022];
void dfs(int node,int pa)
{
	par[node] = pa;
	for(int i=0;i<vv[node].size();i++)
	{
		int nn = vv[node][i];
		if(nn==pa)
			continue;
		dfs(nn,node);
		mh[node] = max(mh[node],mh[nn]+1);
	}
}
int main()
{
	int n,u,v;
	scanf("%d%d%d",&n,&u,&v);
	for(int i=1;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		vv[a].push_back(b);
		vv[b].push_back(a);
	}
	dfs(v,-1);
	int dis = 0,tt = u;
	while(tt!=v)
	{
		dis++;
		tt = par[tt];
	}
	dis = (dis-1)/2;
	while(dis--)
		u = par[u];
	int len = mh[u];
	while(u!=v)
	{
		len++;
		u = par[u];
	}
	cout<<(len-1)<<endl;
	return 0;
}