#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using ll = long long;
using namespace std;

int n, u, v, a, b, dist[100010];
vector<int> g[100010];

void rec1(int v, int p, int d) {
	dist[v] = d;

	for(int nv : g[v]) {
		if (nv == p) continue;
		rec1(nv, v, d + 1);
	}
}

int rec2(int v, int p, int d) {
	if (d >= dist[v]) return 0;

	int res = dist[v] - 1;
	for (int nv : g[v]) {
		if (nv == p) continue;
		res = max(res, rec2(nv, v, d + 1));
	}
	return res;
}

int main()
{
	cin >> n >> u >> v;
	--u, --v;
	for (int i = 0; i < n - 1; ++i) {
		cin >> a >> b;
		--a, --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	rec1(v, -1, 0);
	cout << rec2(u, -1, 0);
	return 0;
}