#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
int n, taka, aoki, pa[N], dpst[N], depth[N];
vector<int> adj[N];

void dfs(int u) {
	dpst[u] = 0;
	for (int v : adj[u])
		if (v != pa[u]) {
			pa[v] = u;
			depth[v] = depth[u] + 1;
			dfs(v);
			dpst[u] = max(dpst[u], dpst[v] + 1);
		}
}
int finaltag(int dist) {
	if (dist < 2) return 0;
	return dist - 1;
}

int main() {
	cin >> n >> taka >> aoki;
	for (int i = 1; i < n; ++i) {
		int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u);
	}
	pa[aoki] = -1; depth[aoki] = 0;
	dfs(aoki);
	int dist = depth[taka];
	int ans = 0, aokiApproach = 0;
	for (int u = taka; dist > 0; dist -= 2, u = pa[u], aokiApproach++) {
		ans = max(ans, finaltag(dist) + dpst[u] + aokiApproach);
	}
	cout << ans << endl;
}