#include "bits/stdc++.h"
using namespace std;
int N;
vector<int>to[100005];
vector<int>dist;
bool dfs(int v, int d = 0, int p = -1) {
	dist[v] = d;
	for (int e : to[v]) {
		if (p == e) {
			continue;
		}
		dfs(e,d+1,v);
	}
	return false;
}
vector<int>f(int x) {
	dist = vector<int>(N);
	dfs(x);
	return dist;
}

int main() {
	int u, v;
	cin >> N >> u>> v;
	u--;
	v--;
	for (int n = 0;n<N-1;++n) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	vector<int>DistU =f(u);
	vector<int>DistV =f(v);
	int ans = 0;
	for (int n = 0;n<N;++n) {
		if (DistU[n] < DistV[n]) {
			ans = max(ans, DistV[n]);
		}
	}
	cout << ans -1<<endl;
	return 0;
}