#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, u, v; cin >> n >> u >> v; u--; v--;
	vector<vector<int>> to(n);
	for(int i = 0; i < n - 1; i++){
		int x, y; cin >> x >> y; x--; y--;
		to[x].push_back(y);
		to[y].push_back(x);
	}
	function<void(int,int,vector<int>&)> dfs = [&](int u, int p, vector<int> &d){
		for(int v : to[u]){
			if(v == p) continue;
			d[v] = d[u] + 1;
			dfs(v, u, d);
		}
	};
	vector<int> du(n, 0), dv(n, 0);
	dfs(u, -1, du);
	dfs(v, -1, dv);
	int ans = du[v] / 2;
	for(int i = 0; i < n; i++){
		if(du[i] < dv[i]){
			ans = max(ans, dv[i] - 1);
		}
	}
	cout << ans << endl;
	return 0;
}
