#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

vector<int> G[100010];
int d[2][100010];
void dfs(int s, int v, int parent) {
	for (int to : G[v]) {
		if (to == parent) continue;
		d[s][to] = d[s][v] + 1;
		dfs(s, to, v);
	}
}
int main()
{
	int N, u, v;
	cin >> N >> u >> v;
	u--; v--;
	for (int i = 0; i < N - 1; i++) {
		int A, B;
		cin >> A >> B;
		A--; B--;
		G[A].push_back(B);
		G[B].push_back(A);
	}
	dfs(0, u, -1);
	dfs(1, v, -1);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (d[0][i] < d[1][i]) {
			ans = max(ans, d[1][i] - 1);
		}
	}
	cout << ans << endl;
}