#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> > tree(n);
	for (int i = 1; i < n; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	vector< vector<int> > depth(2, vector<int>(n));
	function<void(int, int, int, int)> dfs = [&](int u, int d, int p, int x) {
		depth[x][u] = d;
		for (int v : tree[u]) {
			if (v == p) continue;
			dfs(v, d + 1, u, x);
		}
	};
	dfs(u, 0, -1, 0);
	dfs(v, 0, -1, 1);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (depth[0][i] < depth[1][i]) {
			ans = max(ans, depth[1][i]);
		}
	}
	cout << ans - 1 << '\n';
	return 0;
}
