#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;

vector<int> to[100005];
vector<int> dist;
int n;

void dfs(int v, int s = 0, int p = -1) {
	dist[v] = s;
	for (int u : to[v]) {
		if (u == p) continue;
		dfs(u, s + 1, v);
	}
}

vector<int> calcDist(int s) {
	dist = vector<int>(n);
	dfs(s);
	return dist;
}

int main() {
	int u, v;
	cin >> n >> u >> v;
	--u; --v;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	int ans = 0;
	vector<int> A = calcDist(u);
	vector<int> T = calcDist(v);
	for (int i = 0; i < n; ++i) {
		if (A[i] < T[i]) {
			ans = max(ans, T[i]-1);
		}
	}
	cout << mx << endl;
	return 0;
}