#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
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 p ,int v, int parent) {
	for (int i = 0; i < G[v].size(); i++) {
		if (G[v][i] == parent) continue;
		d[p][G[v][i]] = d[p][v] + 1;
		dfs(p, G[v][i], v);
	}
}
int main()
{
	int N, u, v;
	cin >> N >> 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);
	}
	u--; v--;
	d[0][u] = 0;
	d[1][v] = 0;
	dfs(0, u, -1);
	dfs(1, v, -1);
	int ans = 0, num = 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;
}
