#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

vector<int> G[100010];

void dfs(int v, int p, int dist, vector<int> &d){
	d[v] = dist;
	for(auto u : G[v]){
		if(u == p) continue;
		dfs(u, v, dist + 1, d);
	}
}

signed main(){
	int n, u, v;
	cin >> n >> u >> v;
	u--; v--;
	rep(i, 0, n - 1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<int> dt(n, INF), da(n, INF);
	dfs(u, -1, 0, dt);
	dfs(v, -1, 0, da);
	int ans = 0;
	rep(i, 0, n){
		if(dt[i] < da[i]){
			ans = max(ans, da[i] - 1);
		}
	}
	cout << ans << endl;
}