#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 100005, INF = 1e9;
int n, u, v, a, b, d[2][MX], ans;
vector<int> G[MX];
void dfs(int u, int p, int t){
	if(u!=p) d[t][u] = d[t][p]+1;
	for(int ch: G[u]) if(ch != p && d[!t][ch] > d[t][u]+1) dfs(ch,u,t);
}

int main(){
	scanf("%d%d%d", &n, &u, &v);
	u--; v--;
	rep(i,n-1){
		scanf("%d%d", &a, &b);
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	fill(d[1],d[1]+n,INF);
	dfs(v,v,0);
	d[1][u] = 0;
	dfs(u,u,1);
	rep(i,n) if(d[1][i] != INF) ans = max(ans,d[0][i]-1);
	printf("%d\n", ans);
}